You are on page 1of 18

Department of Information Technology

Bachelor of Technology
in
Information Technology

IT 202 - Database Management System

Submitted To: Submitted By:


Ms. Nisha Singh Satwik Bhutani
(Department of Information Technology) (2K22/IT/146)

Delhi Technological University (Formerly


Delhi College of Engineering)Bawana
Road, Delhi-110042
LIST OF EXPERIMENTS

S.N. Assignment Date

1 To demonstrate the use of DDL and DML commands


2 ER Diagram

3 Use of Integrity Constraints

4 Use of Alter commands

5 To implement Joins
6

9
EXPERIMENT-1

AIM: TO STUDY AND IMPLEMENT DDL AND DML COMMANDS

DDL (Data Definition Language):

Data Definition Language 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. DDL is a set of SQL commands used to create,
modify, and delete database structures but not data. These commands are
normally not used by a general user, who should be accessing the database
via an application.

DDL COMMANDS AND THEIR APPLICATIONS:


1. CREATE :
This command is used to create a new table in SQL. The user must give
information like table name, column names, and their datatypes.

2. ALTER :
This command is used to add, delete or change columns in the existing
table. The user needs to know the existing table name and can do add,
delete or modify tasks easily.
3. RENAME:
It is possible to change name of table with or without data in it using
simple RENAME command. We can rename any table object at any
point of time.
4. TRUNCATE:
This command is used to remove all rows from the table, but the
structure of the table still exists.

5. DROP:
This command is used to remove an existing table along with its
structure from the Database.
6. COMMENT:
This command is used to write down comments in SQL queries.
DML (Data Manipulation Language)

DML statements are used for managing data with in schema objects.
DML are of two types –
1. Procedural DMLs : require a user to specify what data are needed and
how to get those data.
2. Declarative DMLs (also referred as Non-procedural DMLs) : require a
user to specify what data are needed without specifying how to get
those data.
Declarative DMLs are usually easier to learn and use than procedural
DMLs. However, since a user does not have to specify how to get the
data, the database system has to figure out an efficient means of
accessing data.

DML COMMANDS AND THEIR IMPLEMENTATION:


1. INSERT:
Insert command is used to insert data into a table.
2. SELECT:
Select command is used to retrieve data from the database.

3. DELETE:
Delete command is used to delete records from a database table.
4. UPDATE:
Update command is used to update existing data within a table.
EXPERIMENT-2

TOPIC: FLIGHT RESERVATION SYSTEM

SCHEMA:
1. Airports:
• airport_id (primary key)- stores unique id for every airport
• airport_name- stores name of each airport
• city- stores the city of the airport
• country- stores the country of the airport

2. Flights:
• flight_id (primary key)- stores unique id for every airport
• departure_airport_code (foreign key to airport)- stores the airport id
of the departure airport
• arrival_airport_code (foreign key to airport)- stores the airport id of
the departure airport
• departure_datetime- stores date and time at departure
• arrival_datetime- stores date and time at arrival
• available_seats- stores no. of seats available
• total_seats- stores no. of total seats
• base_price- stores the price of each seat

3. Passengers:
• passenger_id (primary key)- stores unique id for every passenger
• name- stores name of the given passenger
• gender- stores gender of the given passenger
• email- stores email of the given passenger

4. Reservations:
• reservation_id (primary key)- stores unique id for every reservation
• flight_id (foreign key to flights)- stores flight id of the booked flight
• passenger_id (foreign key to passengers)- stores the passenger id of
the passenger who has made the booking
• no_of_booked_seats- stores no. of seats which are booked
• total_fare- stores total fare of the booking

ER DIAGRAM:
EXPERIMENT-3

Integrity Constraints:
Integrity constraints are rules that enforce the integrity of data stored in a
database. They ensure that data remains accurate, consistent, and reliable over
time. These constraints prevent users from entering invalid data or performing
actions that would compromise the integrity of the database.
There are several types of integrity constraints in relational databases,
including:

1. Entity Integrity Constraint (Primary Key Constraint):


• The entity integrity constraint ensures that each row in a table is
uniquely identifiable by its primary key.
• It prevents the primary key column (or columns) from containing null
values or duplicate values.
• By enforcing this constraint, it guarantees the uniqueness and non-
nullability of the primary key, which helps maintain data integrity.

2. Referential Integrity Constraint (Foreign Key Constraint):


• The referential integrity constraint maintains the relationships
between tables by ensuring that values in a foreign key column
correspond to values in a related primary key column in another
table.
• It prevents the creation of orphan records and maintains data
consistency across related tables.

3. Domain Integrity Constraint:


• The domain integrity constraint enforces the data type, format, and
range of values allowed in a column.
• It ensures that only valid data is stored in a column based on its
defined data type and constraints.

4. Check Constraint:
• The check constraint allows you to define specific conditions that
must be met for data to be inserted or updated in a column.
• It ensures that only data meeting the specified conditions can be
stored in the column.

5. Unique Constraint:
• The unique constraint ensures that all values in a column (or
combination of columns) are unique and not duplicated.
• It prevents the insertion of duplicate values in the specified
column(s).

These integrity constraints collectively help maintain the accuracy, consistency,


and reliability of the data stored in a database, thereby ensuring its integrity.
EXPERIMENT-4

Use of Alter Commands:


1. Add a column:

2. Modify Datatype of a Table:

3. Drop a column:

4. Renaming a column:
5. Renaming a Table:

6. Add a Constraint:

7. Drop a Constraint:
EXPERIMENT 5

AIM- To implement different types of JOIN statements


DESCRIPTION- SQL Join statement is used to combine data or rows from two or
more tables based on a common field between them.
1) INNER JOIN - The INNER JOIN keyword selects all rows from both the tables
as long as the condition is satisfied.

2) LEFT JOIN - This join returns all the rows of the table on the left side of the
join and matches rows for the table on the right side of the join.
3) RIGHT JOIN - This join returns all the rows of the table on the right side of
the join and matching rows for the table on the left side of the join

4) FULL JOIN - FULL JOIN creates the result-set by combining results of both
LEFT JOIN and RIGHT JOIN. The result-set will contain all the rows from both
tables.

5) CROSS JOIN - It is a type of join that returns the Cartesian product of rows
from the tables in the join.

You might also like