0% found this document useful (0 votes)
16 views

Da1 Dbms (Lab)

Uploaded by

Kajari Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Da1 Dbms (Lab)

Uploaded by

Kajari Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

School of Computer Science Engineering (SCOPE)

Name: Tirthankar Gupta


Registration
No. : 21BCE0324
Date:
06.05.2023

Assessment 1
Exercise: II
Aim: To know how the constraints are used to make table is consistent.

Table Name: Employee

Attribute Data Type Constraint


First Name Varchar (15) Not Null
Mid Name Char(2)
Last Name Varchar (15) Not Null
SSN Number Char (9) Primary Key
Birthday Date
Address Varchar (50)
Sex Char(1) Sex In (M,F,m,f)
Salary Number (7) Default 800
Supervisor SSN Char (9) Foreign Key Employee (SSN)
on delete set null
Department number Number(5) Foreign key to department
number of department table on
delete cascade

Table Name : Department

Attribute Data type Constraint


Department Name Varchar(15) Not Null
Department number INT(5) Primary key
Manager SSN Char (9) Foreign key-Employee (SSN)
on delete set null
Manage start date Date

Table Name : Dept_locations


Attribute Data type Constraint
Department Number Number(5) Department (dep no) onDelete
Cascade
Department Location Varchar (15)

Table Name: Project

Attribute Data type Constraint


Project Name Varchar2(15) Not Null
Project number Number(5) Primary key
Project Location Varchar2(50)
Department Number Number(5) Foreign Key –Department (dep
no ) on delete set null
Table Name: Works_On

The combination of Employee SSN and Project Number must be a Primary Key

Attribute Data type Constraint


Employee SSN Char (9) Foreign Key
Employee (SSN) on delete cascade
Project number INT(5) Foreign Key project ( Pnumber ) on
delete cascade
Hours Decimal (3,1) Not null

Name: Dependent

The combination of Employee SSN and Dependent Name must be a Primary Key.

Attribute Datatype Constraint


Employee Char (9) Foreign Key- Employee (SSN) on Delete
Cascade
Dependent Name Varchar(15)
Sex Char(1) Check Sex in (M,F,m,f)
Birthday Date
Relationship Varchar(8)
Code Snippet
Output
Questions

1. Insert ('Robert', 'F', 'Scott', '943775543', '21-JUN-42', '2365 Newcastle Rd,


Bellaire, TX', M, 58000, '888665555', 1 ) into EMPLOYEE.
2. Insert ( '677678989', null, '40.0' ) into WORKS_ON.
3. Insert ( '453453453', 'John', M, '12-DEC-60', 'SPOUSE' ) into DEPENDENT
4. Delete the WORKS_ON tuples with ESSN= '333445555'.
5. Modify the MGRSSN and MGRSTARTDATE of the DEPARTMENT tuple with
DNUMBER=5 to '123456789' and '01-OCT-88', respectively.

Tables after update

You might also like