Question 1 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) i) What is Hamid office number? ii) Assume that lecturer Hamid changes his name to Daud. Show the SQL statements to make the appropriate changes. iii) What are the names of students who got 75 marks and above for any courses? iv) Find the names of all current students taking course IAS2143. v) Find the names of the lecturers who teach each course. vi) Remove data for student’s name Nabila where her student ID is 200. (20 marks) Answer: i) SELECT FROM WHERE OfficeNumber LECTURER L_Name = ‘Hamid’ (3 marks) ii) UPDATE SET WHERE LECTURER L_Name = ‘Daud’ L_Name = ‘Hamid’ (3 marks) iii) SELECT FROM WHERE AND STUDENT.S_Name STUDENT, COURSEWORK STUDENT.SID = COURSEWORK.SID COURSEWORK.Marks >= 75 (4 marks) iv) SELECT FROM STUDENT.S_Name STUDENT, COURSEWORK WHERE AND STUDENT. SID = COURSEWORK.SID COURSEWORK.CourseID = ‘IAS2143’ (4 marks) v) SELECT FROM WHERE AND COURSE.Lecturer COURSE, COURSEWORK, STUDENT COURSE.CourseID = COURSEWORK.CourseID COURSEWORK.SID = STUDENT.SID (4 marks) vi) DELETE WHERE STUDENT S_Name = ‘Nabila’ and SID = ‘200’ (2 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. Gallery Customer History Form Customer Name Miss Fatimah Yusof 21 Jalan Meranti Satu Taman Sri Muda 40400 Shah Alam Selangor Phone (013) 323 6000 Purchases Made Artist Title Purchase Date Sales Price 03 - Carol Channing 15 - Dennis Frings 03 - Carol Channing 15 - Dennis Frings Laugh with Teeth South toward Emerald Sea At the Movies South toward Emerald Sea 09/17/2000 05/11/2000 02/14/2002 07/15/2003 7000.00 1800.00 5550.00 2200.00 Based on the above relation structure, create a new relation structure using record layout in: i) Create un-normalize form of relational schema ii) First Normal Form (1NF) iii) Second Normal Form (2NF) iv) Third Normal Form (3NF) (10 Marks) Answer i) Un-normalize form customer [ custno, cust_name, cust_addr, cust_phone, ( artist_id, artist_name, art_title, pur_date, price) ] ( 1 mark) ii) First Normal Form (1NF) customer [ custno, cust_name, cust_addr, cust_phone] cust_art [ custno, art_code, pur_date, artist_id, artist_name, art_title, price ] 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) customer [ custno, cust_name, cust_addr, cust_phone] cust_art [ custno, art_code, pur_date, price ] art [ art_code, art_title, artist_id, artist_name ] (1m x 3 = 3marks) v) Third Normal Form (3NF) customer [ custno, cust_name, cust_street, cust_city, cust_prov, cust_pstlcd, cust_phone] cust_art [ custno, art_code, pur_date, price ] art [ art_code, art_title, artist_id(FK) ] artist [ artist_id, artist_name ] (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: consists UNIVERSITY 1 FACULTY M 1 has M PROGRAMME M run DEPARTMENT 1 1 compose M SUBJECT M teaches LECTURER N M enroll N STUDENT (Each entity 1 mark x 7 = 7 marks, each r/ship ½ m x 6 = 3 marks; total 10 marks)