Lab3 ERD2Relational Fa2022
Lab3 ERD2Relational Fa2022
Write SQL queries to create tables with keys and relations corresponding to each of the
following question. Note that you should submit Q1.sql for Question 1, Q2.sql for Question
2,…
To submit, select all your .sql file and compress into a .zip file named
YourRollNumber_YourName.zip
NOTICE that when creating the SQL commands as request, you MUST keep the name
of tables, relationships, attributes and data type of attributes as SAME as given in the
given ERD.
Attributes have written with underline are Primary Key of each entity.
Attributes which reference to the primary key of another table must have the same
name as the attributes in the primary key of the referencing table.
When submitting the responses for this question, submit only SQL statements for
creating tables with corresponding keys and foreign keys. No SQL statement specifying
the database name like create database, alter database or use database_name is
accepted.
Question 1 (Q1.sql):
Gender: bit
hours: int
hourSalary:
money Jobs
has Employees
BirthDate:
Date
BelongsTo
WorkFor
ToDate:
Date
Departments FromDate:
Date
NbOfHours:
int
ExNumber: Description: Name:
int ntext nvarchar(90)
SectionNo:
int
Mark: float
BelongTo
Courses
Credits:
CourseID: int Name: int
nvarchar(100)
Question 3 (Q3.sql): Note that when an entity has a role named “RName” in a relationship,
please use RName_PName for the name of attributes referencing to the primary key of this
entity; where RName is the name of the role and PName is the name of attribute in the
primary key of the entity.
DepartureTime:
Flight#: AirportCode: AirportName:
Time
varchar(10) varchar(10) nvarchar(50)
Go City:
nvarchar(20)
Duration: int
To
Date: Date
Company:
AirPlane#: Airplanes varchar(20)
varchar(10)
SeatNumbers:
int
Question 4 (Q4.sql): Please transform the subclasses into tables by using entity relationship
conversion.
Department: Gender:
StaffID
nvarchar(50) char(1)
varchar(11)
Name:
nvarchar(50)
Belong
IsA
specialty:
Rooms Doctors nvarchar(50)