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

Assignment 1 - 21bce0324dbms

Uploaded by

Kajari Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Assignment 1 - 21bce0324dbms

Uploaded by

Kajari Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

TIRTHANKAR GUPTA

21BCE0324

School of Computer Science Engineering (SCOPE)

Name: Tirthankar Gupta

Registration No. : 21BCE0324

Date: 06.05.2023

Assessment 1
Exercise: I

EMPLOYEE
TIRTHANKAR GUPTA
21BCE0324

DEPARTMENT

PROJECT

3.
TIRTHANKAR GUPTA
21BCE0324

4.

5.

6.

7
TIRTHANKAR GUPTA
21BCE0324

8.

9.
TIRTHANKAR GUPTA
21BCE0324

10.

11.

12.
TIRTHANKAR GUPTA
21BCE0324
TIRTHANKAR GUPTA
21BCE0324
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
TIRTHANKAR GUPTA
21BCE0324
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)
TIRTHANKAR GUPTA
21BCE0324

Code Snippet
TIRTHANKAR GUPTA
21BCE0324
TIRTHANKAR GUPTA
21BCE0324
TIRTHANKAR GUPTA
21BCE0324
TIRTHANKAR GUPTA
21BCE0324
TIRTHANKAR GUPTA
21BCE0324
Output
TIRTHANKAR GUPTA
21BCE0324
TIRTHANKAR GUPTA
21BCE0324
TIRTHANKAR GUPTA
21BCE0324
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.
TIRTHANKAR GUPTA
21BCE0324
Tables after update
TIRTHANKAR GUPTA
21BCE0324
Questions

1. Add Foreign Keys using Alter Table [if not done earlier].
2. Drop Foreign key defined on SuperSSN and add it using Alter table command.
3. Make name of Project as Unique and sex of employee as not null.
4. Make Address as a new type containing door no, street, city, State, Continent.
5. Make salary of employee to accept real values.
TIRTHANKAR GUPTA
21BCE0324
Tables after update

You might also like