You are on page 1of 19

Experiment No-1

Aim: Introduction to Database.

Theory:

A database, in the most general sense, is an organized collection of data. More


specifically, a database is an electronic system that allows data to be easily
accessed, manipulated and updated.

A database management system (DBMS) refers to the technology for creating and
managing databases. DBMS is a software tool to organize (create, retrieve,
update, and manage) data in a database.

The main aim of a DBMS is to supply a way to store up and retrieve database
information that is both convenient and efficient. By data, we mean known facts
that can be recorded and that have embedded meaning. Usually, people use
software such as DBASE IV or V, Microsoft ACCESS, or EXCEL to store data in
the form of a database. A datum is a unit of data. Meaningful data combined to
form information. Hence, information is interpreted data - data provided with
semantics. MS. ACCESS is one of the most common examples of database
management software.

More on Data, Information, and Knowledge

Knowledge refers to the useful use of information. As you know, that information
can be transported, stored, and shared without any problems and difficulties, but
the same cannot be said about knowledge. Knowledge necessarily involves
personal experience and practice.

Database systems are meant to handle an extensive collection of information.


Management of data involves both defining structures for storage of information
and providing mechanisms that can do the manipulation of those stored
information. Moreover, the database system must ensure the safety of the
information stored, despite system crashes or attempts at unauthorized access.

Why Use DBMS?

• To develop software applications In less time.


• Data independence and efficient use of data.
• For uniform data administration.
• For data integrity and security.
• For concurrent access to data, and data recovery from crashes.
• To use user-friendly declarative query language.
Where is a Database Management System (DBMS) being Used?

• Airlines: reservations, schedules, etc


• Telecom: calls made, customer details, network usage, etc
• Universities: registration, results, grades, etc
• Sales: products, purchases, customers, etc
• Banking: all transactions etc

Advantages of DBMS

A DBMS manages data and has many benefits. These are:

• Data independence: Application programs should be as free or independent


as possible from details of data representation and storage. DBMS can
supply an abstract view of the data for insulating application code from
such facts.
• Efficient data access: DBMS utilizes a mixture of sophisticated concepts
and techniques for storing and retrieving data competently. This feature
becomes important in cases where the data is stored on external storage
devices.
• Data integrity and security: If data is accessed through the DBMS, the
DBMS can enforce integrity constraints on the data.
• Data administration: When several users share the data, integrating the
administration of data can offer significant improvements. Experienced
professionals understand the nature of the data being managed and can be
responsible for organizing the data representation to reduce redundancy and
make the data to retrieve efficiently.

Components of DBMS

• Users: Users may be of any kind such as DB administrator, System


developer, or database users.
• Database application: Database application may be Departmental, Personal,
organization's and / or Internal.
• DBMS: Software that allows users to create and manipulate database
access,
• Database: Collection of logical data as a single unit.

There are four types of Data Languages

1. Data Definition Language (DDL)


2. Data Manipulation Language(DML)
3. Data Control Language(DCL)
4. Transactional Control Language(TCL)

DDL is the short name for Data Definition Language, which deals with
database schemas and descriptions, of how the data should reside in the
database.

• CREATE: to create a database and its objects like (table, index, views, store
procedure, function, and triggers)
• ALTER: alters the structure of the existing database
• DROP: delete objects from the database
• TRUNCATE: remove all records from a table, including all spaces allocated
for the records are removed
• COMMENT: add comments to the data dictionary
• RENAME: rename an object

DML is the short name for Data Manipulation Language which deals with data
manipulation and includes most common SQL statements such SELECT,
INSERT, UPDATE, DELETE, etc., and it is used to store, modify, retrieve,
delete and update data in a database.
• SELECT: retrieve data from a database
• INSERT: insert data into a table
• UPDATE: updates existing data within a table
• DELETE: Delete all records from a database table
• MERGE: UPSERT operation (insert or update)
• CALL: call a PL/SQL or Java subprogram
• EXPLAIN PLAN: interpretation of the data access path
• LOCK TABLE: concurrency Control

DCL is short for Data Control Language which acts as an access specifier to the
database.(basically to grant and revoke permissions to users in the database
• GRANT: grant permissions to the user for running DML(SELECT, INSERT,
DELETE,…) commands on the table
• REVOKE: revoke permissions to the user for running DML(SELECT,
INSERT, DELETE,…) command on the specified table

TCL is short for Transactional Control Language which acts as an manager for
all types of transactional data and all transactions.Some of the command of TCL
are
• Role Back: Used to cancel or Undo changes made in the database
• Commit: It is used to apply or save changes in the database
• Save Point: It is used to save the data on the temporary basis in the database

Database Management System: The software which is used to manage


databases is called Database Management System (DBMS). For Example,
MySQL, Oracle, etc. are popular commercial DBMS used in different
applications. DBMS allows users the following tasks:
• Data Definition: It helps in the creation, modification, and removal of
definitions that define the organization of data in the database.
• Data Updation: It helps in the insertion, modification, and deletion of the
actual data in the database.
• Data Retrieval: It helps in the retrieval of data from the database which can
be used by applications for various purposes.
• User Administration: It helps in registering and monitoring users, enforcing
data security, monitoring performance, maintaining data integrity, dealing
with concurrency control, and recovering information corrupted by
unexpected failure.

Code and Output

CREATE
Used to create a Table in the database.

INSERT

It is used to insert data into the table.


SELECT

It is used to retrieve data from the database.

UPDATE
It is used to update the existing data from the database.
ALTER Table

It is used to for altering the table structure, such as, to add a column to existing
table, to rename any existing column, to change datatype of anycolumn or to
modify its size and to drop a column from the table.

Learnings/ Conclusion:

In this experiment, we learnt about various queries. We implemented the commands-


create tables, add columns, insert data, update data, drop tables etc.
Experiment No-2

AIM: Various Types of Relational Database systems

THEORY:

RDBMS stands for Relational Database Management System. At its core, a


relational database management system is a database management system
that organizes data into structured tables. These tables are related to each
other based on predefined rules to ensure data integrity.
A relational database management system supports the relational model,
which means the data and relationships are represented using tables. It also
uses a structured querying language (SQL) for querying and maintaining the
database.

Types of relational database management system


Relational database management system platforms have seen significant
evolution over the years, with various systems catering to different needs and
scales.

Here are some of the most popular types of relational database


management systems:
Oracle database
MySQL
Microsoft SQL server
PostgreSQL
SQLite
MariaDB
Let us understand each type of relational database management
system in detail:

1. Oracle database

Pros: Oracle database is revered for its robustness, high performance, and
advanced features like Real Application Clusters (RAC) for fault tolerance
and scalability.
With a comprehensive suite of tools and widespread industry adoption, it’s
a favorite for mission-critical applications in large enterprises.
Additionally, Oracle offers deep integration capabilities with cloud
platforms, facilitating hybrid and cloud-native architectures. Its security
features, like advanced encryption and data masking, further ensure that
sensitive information remains protected, making it a top choice for sectors
requiring stringent data protection.

Cons: While it’s powerful, it might not offer the same performance levels
for specific tasks as some commercial databases. Some users also find its
learning curve slightly steeper.
Additionally, transitioning from other systems to Oracle can be resource-
intensive, and the company’s support structure may sometimes be viewed as
bureaucratic, leading to slower resolution of minor issues.

2. MySQL

Pros: Being open-source, MySQL offers cost advantages, especially for


startups and SMEs. Its reputation for speed, reliability, and a large supportive
community make it a go-to for many web-based applications.
Additionally, its widespread adoption has led to a plethora of tools and
integrations, simplifying database management tasks. Furthermore, its
modular architecture allows for customizable configurations, catering to
varied performance needs.

Cons: Some advanced features available in other commercial databases


might be lacking in MySQL. Post-acquisition by Oracle, concerns regarding
its open-source future have arisen. Additionally, in high-demand scenarios,
MySQL might exhibit performance bottlenecks.
Furthermore, its default configuration may not always offer the security
levels required for critical enterprise applications.
3. Microsoft SQL server

Pros: SQL server offers excellent integration with other Microsoft products,
making it a natural choice for businesses invested in the Microsoft
ecosystem. It’s known for its ease of use, strong security features, and
comprehensive toolset.
Additionally, its cloud integration with Azure makes scalability and data
recovery more seamless. Its business intelligence capabilities, integrating
tools like Power BI and SSRS, ensure dynamic reporting and analytics for
businesses.

Cons: Licensing costs can be on the higher side. It’s historically bound to
the Windows platform, though recent versions offer Linux support.
Furthermore, there’s a potential learning curve for those unfamiliar with the
Microsoft ecosystem. The system might also require periodic tuning and
optimisation to handle very large datasets efficiently.

4. PostgreSQL

Pros: PostgreSQL is lauded for its extensibility, supporting both relational


and non-relational data models. It offers a robust set of features, and being
open-source, it attracts a diverse developer community.
Furthermore, its advanced data types and indexing capabilities make it
highly adaptable to a variety of tasks. Built-in partitioning and its
commitment to SQL standards ensure a versatile and consistent environment
for developers.

Cons: While PostgreSQL is powerful, it might not offer the same


performance levels for specific tasks as some commercial databases. Some
users also find its learning curve slightly steeper. Additionally, in high-
transaction environments, PostgreSQL may require tuning for optimal
performance.
Its community-driven development, though robust, might not always provide
enterprise-level support that larger organisations look for.

5. SQLite

Pros: SQLite’s server less and lightweight nature makes it perfect for mobile
applications and embedded systems. Its simplicity and the fact that it’s self-
contained (with no separate server process) can be advantageous for specific
use cases.
Moreover, its zero-configuration setup means that it’s essentially plug-and-
play, eliminating complex initialisation procedures.
Also, given its wide adoption, there’s a rich trove of documentation and
community support available, making problem-solving more
straightforward for developers.

Cons: It’s not designed for high-concurrency applications or large-scale


systems. Being file-based, there are limitations in terms of scalability.
SQLite lacks certain features found in larger relational database management
system, such as stored procedures or user-defined functions.
Also, while it’s excellent for local storage, it’s not ideal for networked
applications or client-server models due to potential latency.

6. MariaDB

Pros: MariaDB, a fork from MySQL, offers features like the Aria storage
engine and better query optimisation. Being open-source, it enjoys
community-driven enhancements and is perceived as more “open” than
MySQL post the oracle acquisition.
Furthermore, its continuous development promises regular updates and
improvements. The transparent and collaborative nature of its development
ensures that user needs and concerns are addressed promptly.

Cons: Migration from MySQL to MariaDB can sometimes present


challenges. While it aims to maintain drop-in replacement compatibility with
MySQL, there are some differences which might affect specific applications.
In the context of these modern systems, it’s worth noting the trend of
integrating traditional relational database management system capabilities
with features such as in-memory processing, cloud-native architectures, and
compatibility with NoSQL.
The rise of cloud relational database management system solutions is also
evident, offering scalability, reduced operational overhead, and enhanced
reliability.
Experiment No-3

Aim: - Creation of a database and writing SQL queries to retrieve information


from the database.
Theory:-

Creating a database involves the following steps:


1. Define the structure of the database, including the tables, columns, data
types, and relationships between tables.

2. Create the database using a database management system (DBMS) such as


MySQL, PostgreSQL or SQL Server.

3. Populate the tables with data.

Once the database has been created, you can write SQL queries to retrieve
information from it. Some common SQL queries include:

1. SELECT - used to retrieve data from one or more tables. Example: SELECT
* FROM customers;

2. WHERE - used to filter data based on specific conditions. Example:


SELECT * FROM customers WHERE country = 'USA';

3. JOIN - used to combine data from two or more tables based on a related
column between them. Example: SELECT * FROM customers JOIN orders
ON customers.customer_id = orders.customer_id;

4. GROUP BY - used to group data based on one or more columns. Example:


SELECT country, SUM(amount) FROM orders GROUP BY country;

5. HAVING - used to filter data after grouping it. Example: SELECT country,
SUM(amount) FROM orders GROUP BY country HAVING SUM(amount)
> 1000;
Code and Result:-

1. Create a Table:-

2. Insert Data in table

3. Retrieve information from database


4. Update data in the table

Learnings/ Conclusion:

After this experiment, we learnt the different commands in SQL.


Experiment No-4
Aim: To implement DDL (Data Definition Language).

1. Create
2. Alter
3. Drop
4. Truncate

Theory:

DDL Statements
DDL or Data Definition Language actually consists of the SQL commands that
can be used to define the database schema. It simply deals with descriptions of
the database schema and is used to create and modify the structure of database
objects in the database.

Code and Output

CREATE
Used to create a Table in the database.
ALTER Table
It is used to for altering the table structure, such as, to add a column to
existing table, to rename any existing column, to change datatype of any
column or to modify its size and to drop a column from the table.

TRUNCATE

In SQL, the TRUNCATE command is used to remove all the rows from the
table. However, the structure of the table and columns remains the same. It is
faster than the DROP command.
Before truncate

After Truncate
DROP Table

In SQL, the DROP command is used to remove the whole database or table
indexes, data, and more. The important part of this command is that it has the
ability to permanently remove the table and its contents.

Learning/ Conclusion
In this experiment, we learnt about Data Definition Language (DDL)
commands.We implemented the commands- created tables, added columns,
inserted data, updated data, deleted rows, dropped tables etc.
Experiment No-5

Aim: To implement DML (Data ManipulationLanguage) commands.


1. Select
2. Insert
3. Update
4. Delete
Theory:-
DML Statements
Data Manipulation Language (DML) commands are used for managing data
indatabase. DML commands are not auto-committed which means the
changes made by DML command are not permanent to database and can be
rolled back.

Code and Output

INSERT
It is used to insert data into the table.

SELECT
It is used to retrieve data from the database.
Select all data from a table
Select particular data from a table

UPDATE
It is used to update the existing data from the database.

DELETE
It is used to delete any existing record from the table.
Learning/ Conclusion
In this experiment, we learnt about DataManipulation Language (DML)
commands. We implemented the commands- created tables, added columns,
inserted data, updated data, deleted rows, dropped tables etc.

You might also like