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

LAB 1

The document outlines the design of a Company database, including the creation of six tables: EMPLOYEE, DEPARTMENT, DEPT_LOCATIONS, PROJECT, WORKS_ON, and DEPENDENT, with specified primary and foreign keys. It also provides sample data to be inserted into these tables, detailing various attributes such as employee names, department details, project information, and dependent relationships. The focus is on understanding data constraints and relationships within the database structure.

Uploaded by

sagargusainxcube
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)
9 views

LAB 1

The document outlines the design of a Company database, including the creation of six tables: EMPLOYEE, DEPARTMENT, DEPT_LOCATIONS, PROJECT, WORKS_ON, and DEPENDENT, with specified primary and foreign keys. It also provides sample data to be inserted into these tables, detailing various attributes such as employee names, department details, project information, and dependent relationships. The focus is on understanding data constraints and relationships within the database structure.

Uploaded by

sagargusainxcube
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/ 6

Objective: To understand the concept of designing issue related to the database with

creating, populating the tables. To understand the concept of data constraints that is
enforced on data being stored in the table. Focus on Primary Key and the Foreign Key.

a. Create the tables for Company database

TABLE 1: EMPLOYEE

[ Fname VARCHAR(15) NOT NULL,

Minit CHAR,

Lname VARCHAR(15) NOT NULL,

Ssn CHAR(9) NOT NULL,

Bdate DATE,

Address VARCHAR(30),

Sex CHAR,

Salary DECIMAL(10,2),

Super_ssn CHAR(9),

Dno INT NOT NULL,

PRIMARY KEY (Ssn),

FOREIGN KEY (Super_ssn) REFERENCES EMPLOYEE(Ssn),

FOREIGN KEY (Dno) REFERENCES DEPARTMENT(Dnumber)

TABLE 2: DEPARTMENT

[Dname VARCHAR(15) NOT NULL,

Dnumber INT NOT NULL,

Mgr_ssn CHAR(9) NOT NULL,

Mgr_start_date DATE,

PRIMARY KEY (Dnumber),

UNIQUE (Dname),
FOREIGN KEY (Mgr_ssn) REFERENCES EMPLOYEE(Ssn) );

TABLE 3: DEPT_LOCATIONS

( Dnumber INT NOT NULL,

Dlocation VARCHAR(15) NOT NULL,

PRIMARY KEY (Dnumber, Dlocation),

FOREIGN KEY (Dnumber) REFERENCES DEPARTMENT(Dnumber) );

TABLE 4: PROJECT

( Pname VARCHAR(15) NOT NULL,

Pnumber INT NOT NULL,

Plocation VARCHAR(15),

Dnum INT NOT NULL,

PRIMARY KEY (Pnumber),

UNIQUE (Pname),

FOREIGN KEY (Dnum) REFERENCES DEPARTMENT(Dnumber) );

TABLE 5: WORKS_ON

( Essn CHAR(9) NOT NULL,

Pno INT NOT NULL,

Hours DECIMAL(3,1) NOT NULL,

PRIMARY KEY (Essn, Pno),

FOREIGN KEY (Essn) REFERENCES EMPLOYEE(Ssn),

FOREIGN KEY (Pno) REFERENCES PROJECT(Pnumber) );

TABLE 6: DEPENDENT

( Essn CHAR(9) NOT NULL,


Dependent_name VARCHAR(15) NOT NULL,

Sex CHAR,

Bdate DATE,

Relationship VARCHAR(8),

PRIMARY KEY (Essn, Dependent_name),

FOREIGN KEY (Essn) REFERENCES EMPLOYEE(Ssn) );

b. Insert the following data into their respective tables of Company database.

DEPARTMENT

DNAME DNUMBER MGRSSN MGRSTARTDATE

Research 5 333445555 1988-05-22

Administration 4 987654321 1995-01-01

Headquarters 1 888665555 1981-06-19

EMPLOYEE

FNAME LNAME SSN BDATE ADDRESS SEX SALARY SUPERSSN DNO

731
1965- Fondren,
John Smith 123456789 M 30000 333445555 5
01-09 Houston
TX

638 Voss,
1965-
Franklin Wong 333445555 Houston M 40000 888665555 5
12-08
TX

3321
1968-
Alicia Zelaya 999887777 Castle, F 25000 987654321 4
01-19
Spring TX
291 Berry,
1941-
Jennifer Wallace 987654321 Bellaire F 43000 888665555 4
06-20
TX

975 Fire
1962- Oak,
Ramesh Narayan 666884444 M 38000 333445555 5
09-15 Humble
TX

5631 Rice,
1972-
Joyce English 453453453 Houston F 25000 333445555 5
07-31
TX

980
1969- Dallas,
Ahmad Jabbar 987987987 M 25000 987654321 4
03-29 Houston
TX

450
1937- Stone,
James Borg 888665555 M 55000 null 1
11-10 Houston
TX

PROJECT

PNAME PNUMBER PLOCATION DNUM

ProductX 1 Bellaire 5

ProductY 2 Sugarland 5

ProductZ 3 Houston 5

Computerization 10 Stafford 4

Reorganization 20 Houston 1

Newbenefits 30 Stafford 4

WORKS_ON

ESSN PNO HOURS


123456789 1 32.5

123456789 2 7.5

666884444 3 40.0

453453453 1 20.0

453453453 2 20.0

333445555 2 10.0

333445555 3 10.0

333445555 10 10.0

333445555 20 10.0

999887777 30 30.0

999887777 10 10.0

987987987 10 35.0

987987987 30 5.0

987654321 30 20.0

987654321 20 15.0

888665555 20 null

DEPENDENT

ESSN DEPENDENT_NAME SEX BDATE RELATIONSHIP

333445555 Alice F 1986-04-04 Daughter

333445555 Theodore M 1983-10-25 Son

333445555 Joy F 1958-05-03 Spouse

987654321 Abner M 1942-02-28 Spouse

123456789 Michael M 1988-01-04 Son

123456789 Alice F 1988-12-30 Daughter


123456789 Elizabeth F 1967-05-05 Spouse

DEPT_LOCATIONS

DNUMBER DLOCATION

1 Houston

4 Stafford

5 Bellaire

5 Houston

5 Sugarland

You might also like