Consider the following relation's schema of “Teacher” and “Class” and database relations.
Problem Statement:
crossorigin="anonymous">
style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-7200085558568021"
data-ad-slot="3193586076">
Consider the following relation's schema of “Teacher” and “Class” and database relations.
Relations schemas:
Teacher Schema = (TeacherID:Text, Name:Text, Rank:Text, Department:Text, Salary:Number)
Class Schema = (ClassID:Text, CourseCode:Text, DayofWeek:Text, Venue:Text, Department:Text)
Database Relations:
Teacher = { (T001, Dr. Najma Waheed, Professor, CS, 170000), (T002, Dr. Nouman Masood, Assistant
Professor, MGT, 120000), (T003, Dr. Farhana Khan, Professor, CS, 150000), (T004, Dr. Tayyaba Ali, Professor,
CS, 140000), (T005, Mr. Nouman Ahmad, Lecturer, MGT, 80000), (T006, Mr. Waqass Raheem, Lecturer, ENG,
75000)}
Class = { (A001, CS403, Monday, A Block, CS), (B002, MGT101, Tuesday, B Block, MGT), (C003, ENG201, Monday, C Block, ENG), (B005, CS403, Friday, B Block, CS)}
You are required to perform the following tasks:
1. Represent the above database relations as a two-dimensional structure called Table.
2. Perform the following relational algebra operations on the given relations/tables and provide resultant tables.
i. σ Department = ‘CS’ (Teacher) ii. Π ClassID, DayofWeek, Venue (Class)
iii. Π Name, Rank, Department ( σ Rank = ‘Lecturer’ (Teacher) )
crossorigin="anonymous">
style="display:block"
data-ad-format="autorelaxed"
data-ad-client="ca-pub-7200085558568021"
data-ad-slot="6426802817">
Solution:
- Representing
the above database relations as a two-dimensional structure called Table:
Teacher
Table:
TeacherID | Name | Rank | Department | Salary |
T001 | Dr. | Professor | CS | 170000 |
T002 | Dr. | Assistant | MGT | 120000 |
T003 | Dr. | Professor | CS | 150000 |
T004 | Dr. | Professor | CS | 140000 |
T005 | Mr. | Lecturer | MGT | 80000 |
T006 | Mr. | Lecturer | ENG | 75000 |
Class Table:
ClassID | CourseCode | DayofWeek | Venue | Department |
A001 | CS403 | Monday | A | CS |
B002 | MGT101 | Tuesday | B | MGT |
C003 | ENG201 | Monday | C | ENG |
B005 | CS403 | Friday | B | CS |
- Perform
the following relational algebra operations on the given relations/tables
and provide resultant tables.
TeacherID | Name | Rank | Department | Salary |
T001 | Dr. | Professor | CS | 170000 |
T003 | Dr. | Professor | CS | 150000 |
T004 | Dr. | Professor | CS | 140000 |
ii. Π
ClassID, DayofWeek, Venue (Class)
ClassID | DayofWeek | Venue |
A001 | Monday | A |
B002 | Tuesday | B |
C003 | Monday | C |
B005 | Friday | B |
iii. Π Name,
Rank, Department ( σ Rank = ‘Lecturer’ (Teacher) )
Name | Rank | Department |
Mr. | Lecturer | MGT |
Mr. | Lecturer | ENG |
crossorigin="anonymous">
style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-7200085558568021"
data-ad-slot="3193586076">
No comments