SQL 2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Lecturer (ssn: CHAR, name:CHAR, rank:INTEGER, speciality:CHAR)

Ssn 2013-001 2013-002 2013-003 2013-004

Name J. K. Alwis A.D. Perera U.W. Kurey H. Y. Siridasa

Rank 2 1 3 1

Speciality PGD MSc BA MBA

Department ( dno:INTEGER, dname:CHAR, office:CHAR) Dno 101 102 103 Dname Electrical Mechanical Civil office 2nd floor 3rd floor 1st floor

Works_ Dept( dno:INTEGER, prof ssn:CHAR,pc_time:INTEGER) Dno 101 102 103 Ssn 2013-002 2013-003 2013-004 Pc-time 3 2 4

1. Create three tables above using SQL. CREATE TABLE Lecturer ( ssnCHAR(10), nameCHAR(64), rankINTEGER, specialityCHAR(64), PRIMARY KEY ( ssn) ) CREATE TABLE Department ( dnoINTEGER, dnameCHAR(64), officeCHAR(10), PRIMARY KEY (dno) )

CREATE TABLE Works_ Dept ( dnoINTEGER, ssnCHAR(10), pc time INTEGER, PRIMARY KEY (dno,ssn), FOREIGN KEY (prof_ssn) REFERENCES Lecturer, FOREIGN KEY (dno) REFERENCES Department )); 2. List the lecturer ssn who works in electrical department. 3. Display the practical time of lecturers who works in department of civil. 4. How many departments are there?

You might also like