You are on page 1of 11

BCSE302P

Database Systems Lab


LAB ASSESSMENT 1
DDL,Constraints, DML

DDL:
1. Write a SQL statement to create a simple table countries including columns
country_id,country_name and region_id.

2. Add a column population to the country table.

3. Write a SQL statement to create a simple table students including columns student_id,
student_name and dept.

4. Add a column date of join to the students table(use data type as date)
5. Write a SQL statement to create a simple table employees including columns emp_id,
emp_name and designation.

6. Add a column salary to the employees table (use datatype as decimal).

7. Drop all three tables.

Constraints
1. Create the following tables with all given constraints
2. Create the primary key and foreign key constraints using alter command
3. Create all unique constraint using table level constraints
4. Delete all unique constraints using alter command
Bus:

COLOUMN NAME DATA TYPE CONSTRAINT


Bus No varchar2(10) Primary Key
Source varchar2(20) Default Chennai
Destination varchar2(20)
Couch Type varchar2(20) NOT NULL

1.

2.

3.
4.

Reservation

COLOUMN NAME DATA TYPE CONSTRAINT


PNRNo number(9) Primary Key
Journey date Date
No-of-seats integer(8) Should be less than 50
Address varchar2(50)
Contact No Number(9) unique
BusNo varchar2(10) Foreign key
Seat no Number Not NULL

1.

2.
3.

4.

Ticket

COLOUMN NAME DATA TYPE CONSTRAINT


Ticket_No Bus No Primary Key
Journey date Date Not null
Age int(4) Should be greater than 10
Gender Char(10) Not null
Source varchar2(10) Default Chennai
Destination varchar2(10)
Dep-time varchar2(10)
Bus No Number2(10) unique

1.

2.
3

4.

Passenger

COLOUMN NAME DATA TYPE CONSTRAINT


PNR No Number(9) Primary Key
Ticket No Number(9) Foreign key
Name varchar2(15)
Age integer(4) Should be greater than 10
Gender char(10) Not null
Contact no Number(9) Unique
1.

2.
3.

4.

Cancellation:

COLOUMN NAME DATA TYPE CONSTRAINT


PNR No Number(9) Foreign-key
Journey-date Date
Seat no Integer(9) Not null
Contact_No Number(9) unique

1.
2.

3.

4.

DML

Create the following table book(bookname,authorname,price,quantity)

1. Insert 2 rows into the book table and display result table
2. Insert 2 rows in to the book table with same authorname and display
result table

3. Insert 2 rows with values only for book name and author name(use
appropriate syntax) and display result table
4. Increase the price of all books by rs.100 and display result table

5. Display the details of books

6. Display the details of books having price between 400 and 2000

7. Display the names of books with quantity less than 10.


8. Display distinct book authors available

9. Increase the quantity of book1(the first row book data in the table) by 10
and display result table

You might also like