Blog
Database BSSE 3rd Final Past Paper – UOS Main Campus
University of Sargodha main campus (Department of CS & IT) Database final term paper for BSSE 3rd semester (Self), 60 marks, 120 minutes. Retyped from the original paper, with solved answers below.
Solved answers
Q1 – ERD to relations (10)
Primary keys are underlined, foreign keys are marked FK.
- RENTER (RenterID, FirstName, MiddleInitial, LastName, Address, Phone, Email)
- PROPERTY (PropertyID, StreetAddress, CityState, Zip, NbrRooms, BaseRate, PropertyType)
- BEACH_PROPERTY (PropertyID FK → PROPERTY, BlocksToBeach)
- MOUNTAIN_PROPERTY (PropertyID FK → PROPERTY)
- MOUNTAIN_ACTIVITY (PropertyID FK → MOUNTAIN_PROPERTY, Activity) — Activity is shown in brackets, i.e. a multivalued attribute, so it gets its own relation.
- RENTAL_AGREEMENT (AgreementID, BeginDate, EndDate, RentalAmount, RenterID FK → RENTER, PropertyID FK → PROPERTY)
Rules used: each entity becomes a relation; the 1:M relationships Signs and Books are implemented by placing the primary key of the “one” side (Renter, Property) as a foreign key in the “many” side (Rental Agreement). For the disjoint specialization, each subtype becomes a relation with the same primary key as the supertype, and PropertyType (“B” / “M”) is the subtype discriminator.
Q2 – TomKat Entertainment EER (15)
- THEATER (TheaterID, TheaterName, TheaterLocation).
- SCREEN — weak entity identified by TheaterID + ScreenNumber, attribute SeatingCapacity. THEATER 1 —— Contains —— M SCREEN (a theater has one or more screens; each screen belongs to exactly one theater).
- TIME_SLOT — identified by TheaterID + ScreenNumber + SlotDate + StartTime; attributes EndTime, Attendance, Price. SCREEN 1 —— Has —— M TIME_SLOT (slots differ per screen and per day).
- MOVIE (MovieID, Title, Duration, MovieType). MovieType has the values trailer / feature / commercial; you may also draw it as a disjoint, total specialization of MOVIE into TRAILER, FEATURE and COMMERCIAL.
- SHOWING — associative entity for the M:N relationship between TIME_SLOT and MOVIE, with attribute Sequence (1, 2, 3 …) that records the order in which movies are shown in that slot. A time slot shows one or more movies; a movie can be shown in many time slots.
Q3 – Invoice to 3NF (10)
Hospital name and address are the same on every invoice, so they are not stored. Total charges due (1,800 + 75 + 150 + 200 = 2,225) is derived and not stored.
- PATIENT (PatientNo, PatientName, Street, City, State, Zip)
- INVOICE (AccountNumber, PatientNo FK, InvoiceDate, DueDate, DateAdmitted, DateDischarged)
- ITEM (ItemCode, Description)
- INVOICE_LINE (AccountNumber FK, ItemCode FK, Charge)
Why 3NF: the repeating group (code, description, charge) was removed (1NF); Description depends only on ItemCode and patient details depend only on PatientNo, so partial dependencies are removed (2NF); no non-key attribute depends on another non-key attribute (3NF).
Q4 – SQL queries (25)
-- I
SELECT CourseID, CourseName FROM COURSE WHERE CourseID LIKE 'ISM%';
-- II (result: ISM 4212, ISM 4930)
SELECT C.CourseID, C.CourseName
FROM FACULTY F JOIN QUALIFIED Q ON F.FacultyID = Q.FacultyID
JOIN COURSE C ON Q.CourseID = C.CourseID
WHERE F.FacultyName = 'Berndt';
-- III (result: Letersky, Altvater)
SELECT S.StudentID, S.StudentName
FROM STUDENT S JOIN REGISTRATION R ON S.StudentID = R.StudentID
JOIN SECTION SC ON R.SectionNo = SC.SectionNo AND R.Semester = SC.Semester
WHERE SC.SectionNo = 2714 AND SC.CourseID = 'ISM 4212';
-- IV (result: Birkin, Collins)
SELECT F.FacultyID, F.FacultyName
FROM FACULTY F JOIN QUALIFIED Q ON F.FacultyID = Q.FacultyID
WHERE Q.CourseID = 'ISM 3113';
-- V (result: 2143 Birkin and 4756 Collins, so yes)
SELECT FacultyID FROM QUALIFIED
WHERE CourseID = 'ISM 3113'
AND FacultyID NOT IN (SELECT FacultyID FROM QUALIFIED WHERE CourseID = 'ISM 4930');
-- VI (result: 2)
SELECT COUNT(*) AS Enrolled FROM REGISTRATION
WHERE SectionNo = 2714 AND Semester = 'I-2008';
-- VII (result: 1, student 66324 in section 2713)
SELECT COUNT(*) AS Enrolled
FROM REGISTRATION R JOIN SECTION S ON R.SectionNo = S.SectionNo AND R.Semester = S.Semester
WHERE S.CourseID = 'ISM 3113' AND R.Semester = 'I-2008';The results in comments were checked by running the queries on the sample data shown in the paper.
