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

Assignment 2 (22BCE8809)

The document contains SQL commands that create several database tables - EMPLOYEE, DEPARTMENT, DEPT_LOCATIONS, PROJECT, WORKS_ON, and DEPENDENT - and populate them with data. The tables store information about employees, departments, project locations and assignments, employee dependents, and the relationships between them. Descriptions of the tables and SELECT statements are included to view the contents.

Uploaded by

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

Assignment 2 (22BCE8809)

The document contains SQL commands that create several database tables - EMPLOYEE, DEPARTMENT, DEPT_LOCATIONS, PROJECT, WORKS_ON, and DEPENDENT - and populate them with data. The tables store information about employees, departments, project locations and assignments, employee dependents, and the relationships between them. Descriptions of the tables and SELECT statements are included to view the contents.

Uploaded by

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

Assignment 2

Aryan Lunia
[ 22BCE8809 ]

Commands -
CREATE TABLE EMPLOYEE (
Fname VARCHAR(25) ,
Minit CHAR(1),
Lname VARCHAR(25) ,
Ssn NUMBER(9) PRIMARY KEY,
Bdate DATE,
Address VARCHAR(50),
Sex CHAR(1),
Salary NUMBER,
Super_ssn NUMBER(9) ,
Dno NUMBER(2)
);

INSERT INTO EMPLOYEE VALUES (


'John', 'B', 'Smith', 123456789, '1-Jan-1965', '731 Fondren, Houston, TX', 'M',
30000, 333445555, 5
);

INSERT INTO EMPLOYEE VALUES (


'Franklin', 'T', 'Wong', 333445555, '8-Dec-1955', '638 Voss, Houston, TX', 'M',
40000, 888665555, 5
);

INSERT INTO EMPLOYEE VALUES (


'Alicia', '', 'Zelaya', 999887777, '19-Jan-1968', '3321 Castle, Spring, TX', 'F',
25000, 987654321, 4
);

INSERT INTO EMPLOYEE VALUES (


'Jennifer', 'S', 'Wallace', 987654321, '20-Jun-1941', '291 Berry, Bellaire, TX', 'F',
43000, 888665555, 4
);

INSERT INTO EMPLOYEE VALUES (


'Ramesh', 'K', 'Narayan', 666884444, '15-Sep-1962', '975 Fire Oak, Humble,
TX', 'M', 38000, 333445555, 5
);

INSERT INTO EMPLOYEE VALUES (


'Joyce', 'A', 'English', 453453453, '31-Jul-1972', '5631 Rice, Houston, TX', 'F',
25000, 333445555, 5
);

INSERT INTO EMPLOYEE VALUES (


'Ahmad', 'V', 'Jabbar', 987987987, '29-Mar-1969', '980 Dallas, Houston, TX',
'M', 25000, 987654321, 4
);

INSERT INTO EMPLOYEE VALUES (


'James', 'E', 'Borg', 888665555, '10-Nov-1937', '450 Stone, Houston, TX', 'M',
55000, NULL, 1
);

DESC EMPLOYEE;
SELECT * FROM EMPLOYEE;

Output –
Commands -
CREATE TABLE DEPARTMENT (
DName VARCHAR(20) ,
Dnumber NUMBER(2) PRIMARY KEY,
Mgr_ssn NUMBER(9) ,
Mgr_start_date DATE
);

INSERT INTO DEPARTMENT VALUES (


'Research', 5, 333445555, '22-MAY-1998'
);

INSERT INTO DEPARTMENT VALUES (


'Administration',4, 987654321, '1-JAN-1995'
);

INSERT INTO DEPARTMENT VALUES (


'Headquarters',1, 888665555, '19-JUNE-1981'
);

DESC DEPARTMENT;
SELECT * FROM DEPARTMENT;
Output –

Commands -
CREATE TABLE DEPT_LOCATIONS(
Dnumber NUMBER(2),
Dlocation VARCHAR(20)
);

INSERT INTO DEPT_LOCATIONS VALUES (


5, 'Houston'
);

INSERT INTO DEPT_LOCATIONS VALUES (


4, 'Stafford'
);

INSERT INTO DEPT_LOCATIONS VALUES (


5, 'Bellaire'
);

INSERT INTO DEPT_LOCATIONS VALUES (


5, 'Sugarland'
);

INSERT INTO DEPT_LOCATIONS VALUES (


5, 'Houston'
);

DESC DEPT_LOCATIONS;
SELECT * FROM DEPT_LOCATIONS;

Output –

Commands -
CREATE TABLE PROJECT(
Pname VARCHAR(15),
Pnumber NUMBER(2) PRIMARY KEY,
Plocation VARCHAR(10),
Dnum NUMBER(2)
);

INSERT INTO PROJECT VALUES(


'ProductX',1,'Bellaire',5
);
INSERT INTO PROJECT VALUES(
'ProductY',2,'Sugarland',5
);
INSERT INTO PROJECT VALUES(
'ProductZ',3,'Houston',5
);
INSERT INTO PROJECT VALUES(
'Computerization',10,'Stafford',4
);
INSERT INTO PROJECT VALUES(
'Reorganization',20,'Houston',1
);
INSERT INTO PROJECT VALUES(
'Newbenefits',30,'Stafford',4
);

DESC PROJECT;
SELECT * FROM PROJECT;
Output –

Commands -
CREATE TABLE WORKS_ON(
Essn NUMBER ,
Pno NUMBER(2),
Hours DECIMAL
);

INSERT INTO WORKS_ON VALUES(


123456789,1,32.5
);
INSERT INTO WORKS_ON VALUES(
123456789,2,7.5
);
INSERT INTO WORKS_ON VALUES(
666884444,3,40.0
);
INSERT INTO WORKS_ON VALUES(
453453453,1,20.0
);
INSERT INTO WORKS_ON VALUES(
453453453,2,20.0
);
INSERT INTO WORKS_ON VALUES(
333445555,2,10.0
);
INSERT INTO WORKS_ON VALUES(
333445555,3,10.0
);
INSERT INTO WORKS_ON VALUES(
333445555,10,10.0
);
INSERT INTO WORKS_ON VALUES(
333445555,20,10.0
);
INSERT INTO WORKS_ON VALUES(
999887777,30,30.0
);
INSERT INTO WORKS_ON VALUES(
999887777,10,10.0
);
INSERT INTO WORKS_ON VALUES(
987987987,10,35.0
);
INSERT INTO WORKS_ON VALUES(
987987987,30,5.0
);
INSERT INTO WORKS_ON VALUES(
987654321,30,20.0
);
INSERT INTO WORKS_ON VALUES(
987654321,20,15.0
);
INSERT INTO WORKS_ON VALUES(
888665555,20,NULL
);

DESC WORKS_ON;
SELECT * FROM WORKS_ON;

Output –
Commands -
CREATE TABLE DEPENDENT(
Essn NUMBER,
Dependent_name VARCHAR(10),
Sex CHAR(1),
Bdate DATE,
Relationship VARCHAR(10)
);

INSERT INTO DEPENDENT VALUES(


333445555,'Alice','F','5-APRIL-1986','Daughter'
);
INSERT INTO DEPENDENT VALUES(
333445555,'Theodore','M','25-OCT-1983','Son'
);
INSERT INTO DEPENDENT VALUES(
333445555,'Joy','F','3-MARCH-1958','Spouse'
);
INSERT INTO DEPENDENT VALUES(
987654321,'Abner','M','28-FEB-1942','Spouse'
);
INSERT INTO DEPENDENT VALUES(
123456789,'Michael','M','4-JAN-1988','Son'
);
INSERT INTO DEPENDENT VALUES(
123456789,'Alice','F','30-DEC-1988','Daughter'
);
INSERT INTO DEPENDENT VALUES(
123456789,'Elizabeth','F','5-MAY-1967','Spouse'
);

DESC DEPENDENT;
SELECT * FROM DEPENDENT;

Output –

You might also like