0% found this document useful (0 votes)
640 views4 pages

Consider A Student Registration Database Comprising of The Below Given Table Schema

Uploaded by

Dhanu Sree
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)
640 views4 pages

Consider A Student Registration Database Comprising of The Below Given Table Schema

Uploaded by

Dhanu Sree
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/ 4

3. Consider a student registration database comprising of the below given table schema.

(K2,
K4) (A/M’15)

Student File

Student Number Student Name Address Telephone

Course File

Course Number Description Hours Professor Number

Professor File

Professor Number Name Office

Registration File

Student Number Course Number Date

Consider a suitable sample of tuples/records for the above mentioned tables and write DML
statements (SQL) to answer for the queries listed below:

(i) Which courses does a specific professor teach?

(ii) What courses are taught by two specific professors?

(iii) Who teaches a specific course and where is his/her office?

(iv) For a specific student number, in which courses is the student registered and what is
his/her name?

(v) Who are the professors for a specific student?

(vi) Who are the students registered in a specific course?

(vii) o address the given queries, we'll consider the following structure and assume
some sample tuples for each table. Below are SQL Data Manipulation Language
(DML) statements to answer the questions.
(viii) Table Schemas
(ix) 1. Student File

Student_Number Student_Name Address Telephone


101 Alice Smith 123 Elm St 555-1234
102 Bob Johnson 456 Oak St 555-5678

(x) 2. Course File

Course_Number Description Hours Professor_Number


301 Database Systems 3 501
302 Operating Systems 4 502
303 Data Structures 3 501

(xi) 3. Professor File


Professor_Number Name Office
501 Dr. Brown Room 101
502 Dr. Green Room 102

(xii) 4. Registration File

Student_Number Course_Number Date


101 301 2023-09-01
101 302 2023-09-01
102 303 2023-09-02

(xiii) DML Queries


(i) Which courses does a specific professor teach?
To find courses taught by a specific professor (e.g., Professor 501):

SELECT Course_Number, Description

FROM Course_File

WHERE Professor_Number = 501;

Result:

Course_Number Description

301 Database Systems

303 Data Structures

(ii) What courses are taught by two specific professors?

To find courses taught by both Professor 501 and Professor 502:

SELECT Course_Number, Description, Professor_Number

FROM Course_File

WHERE Professor_Number IN (501, 502);

SELECT Course_Number, Description, Professor_Number

FROM Course_File

WHERE Professor_Number IN (501, 502);

Result:

Course_Number Description Professor_Number

301 Database Systems 501

302 Operating Systems 502

303 Data Structures 501

(iii) Who teaches a specific course and where is his/her office?


To find the professor teaching a specific course (e.g., Course 301) and their office:

SELECT Professor_File.Name, Professor_File.Office

FROM Professor_File

JOIN Course_File ON Professor_File.Professor_Number = Course_File.Professor_Number

WHERE Course_File.Course_Number = 301;

Result:

Name Office

Dr. Brown Room 101

iv) For a specific student number, in which courses is the student registered and what is his/her
name?

To find the courses in which a specific student (e.g., Student 101) is registered, and their name:

SELECT Student_File.Student_Name, Course_File.Course_Number, Course_File.Description

FROM Student_File

JOIN Registration_File ON Student_File.Student_Number = Registration_File.Student_Number

JOIN Course_File ON Registration_File.Course_Number = Course_File.Course_Number

WHERE Student_File.Student_Number = 101;

Result:

Student_Name Course_Number Description

Alice Smith 301 Database Systems

Alice Smith 302 Operating Systems

(v) Who are the professors for a specific student?

To find the professors teaching courses that a specific student (e.g., Student 101) is registered for:

SELECT DISTINCT Professor_File.Name

FROM Professor_File

JOIN Course_File ON Professor_File.Professor_Number = Course_File.Professor_Number

JOIN Registration_File ON Course_File.Course_Number = Registration_File.Course_Number

WHERE Registration_File.Student_Number = 101;

Result:

Name

Dr. Brown

Dr. Green
Name

(vi) Who are the students registered in a specific course?

To find the students registered in a specific course (e.g., Course 301):

SELECT Student_File.Student_Name

FROM Student_File

JOIN Registration_File ON Student_File.Student_Number = Registration_File.Student_Number

WHERE Registration_File.Course_Number = 301;

Result:

Student_Name

Alice Smith

These DML statements will work for the given sample data and should be adaptable for a real-world
student registration database.

You might also like