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

SQL 2

The document describes creating three SQL tables - Lecturer, Department, and Works_Dept - to store information about lecturers, departments, and which lecturers work in which departments along with their practical class time. It then provides queries to: 1) List the lecturer ssn who works in the electrical department 2) Display the practical time of lecturers who work in the civil department 3) Count the number of departments
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

SQL 2

The document describes creating three SQL tables - Lecturer, Department, and Works_Dept - to store information about lecturers, departments, and which lecturers work in which departments along with their practical class time. It then provides queries to: 1) List the lecturer ssn who works in the electrical department 2) Display the practical time of lecturers who work in the civil department 3) Count the number of departments
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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