SQL 2
SQL 2
Rank 2 1 3 1
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?