Professional Documents
Culture Documents
Bachelor of Technology
in
Information Technology
5 To implement Joins
6
9
EXPERIMENT-1
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.
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.
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
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:
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).
3. Drop a column:
4. Renaming a column:
5. Renaming a Table:
6. Add a Constraint:
7. Drop a Constraint:
EXPERIMENT 5
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.