Академический Документы
Профессиональный Документы
Культура Документы
a) Analyze the following relational schema and write the SQL code for the given questions.
STUDENT(SID, S_Name, Year)
LECTURER(L_Name, OfficeNumber)
COURSE(CourseID, CourseName, L_Name)
COURSEWORK(SID, CourseID, Marks)
Answer:
i) SELECT OfficeNumber
FROM LECTURER
WHERE L_Name = ‘Hamid’
(3 marks)
v) SELECT COURSE.Lecturer
FROM COURSE, COURSEWORK, STUDENT
WHERE COURSE.CourseID = COURSEWORK.CourseID
AND COURSEWORK.SID = STUDENT.SID
(4 marks)
Question 2
a) The Gill Art Gallery wishes to maintain data on their customers, artists and paintings.
They may have several paintings by each artist in the gallery at one time. Paintings may
be bought and sold several times. In other words, the gallery may sell a painting, then buy
it back at a later date and sell it to another customer.
Customer Name
Purchases Made
i) Un-normalize form
note: the key chosen for the repeating group is the piece of art itself (a code was
assigned), however because a piece of art may be bought by a customer more than once,
the purchase date was added as part of the key to make the rows unique.
(1m x 2 = 2 marks)
iii) Second Normal Form (2NF)
(1m x 4 = 4 marks)
b) Draw an entity-relationship model for the following statement:
A university consists of several faculties. Within each faculty there are several
departments. Each department may run a number of programme. Every programme is
composed of several subjects. A lecturer may teach many subjects and each subject may
be taught by a number of lecturers. All subjects is enrolled by many student.
(10 marks)
Answer:
has
M
enroll
N
STUDENT