Blog
Database System BSSE 3rd Past Paper 2016 – UOS Main Campus
University of Sargodha main campus Database System paper (subjective + practical) for BSSE 3rd, held on 26 January 2016 (90 minutes). Retyped from the original paper, with solved answers below.
Solved answers
Q1 – Differentiate between (5×2)
| Term | Difference |
|---|---|
| Homogeneous vs heterogeneous database | In a homogeneous distributed database every site uses the same DBMS, data model and schema. In a heterogeneous database the sites may use different DBMS products or data models, so gateways or middleware are needed to translate queries. |
| Composite vs multivalued attribute | A composite attribute has component parts (Address → Street, City, Zip). A multivalued attribute can hold several values for one entity instance (Skills, Phone numbers). |
| Entity integrity vs referential integrity | Entity integrity: a primary key cannot be null and must be unique. Referential integrity: a foreign key value must match an existing primary key in the referenced table, or be null. |
| Two-tier vs three-tier architecture | Two-tier: the client application talks directly to the database server (client/server). Three-tier: a middle application/web server holds the business logic between the client and the database, giving better scalability and security. |
| Disjoint rule vs disjointness constraint | The disjointness constraint asks whether a supertype instance can belong to more than one subtype at the same time. The disjoint rule is one answer to it: an instance can belong to at most one subtype (the other answer is the overlap rule). |
Q2 – Short answers (4×2)
1. Entities become tables (relations), attributes become columns, and relationships become foreign keys (an M:N relationship becomes a separate associative table).
2. Maximum cardinality: one-to-one (1:1), one-to-many (1:M), many-to-many (M:N). Minimum cardinality: mandatory (one) or optional (zero).
3. The three-schema architecture (external, conceptual, internal levels) separates the users’ views from the way data is physically stored. Its objective is data independence: the physical storage can change without changing the logical schema (physical independence), and the logical schema can change without changing user views (logical independence).
4. General parameters for choosing a file organization: fast data retrieval, high throughput for processing transactions, efficient use of storage space, protection from failure or data loss, minimal need for reorganization, accommodating growth, and security from unauthorized use. (a) Board of Intermediate Sargodha: mostly read-only result data looked up by roll number in bulk at result time, so efficient storage, fast retrieval by key (indexed file on roll number), accommodating growth every year, and protection from loss and tampering matter most. (b) HBL: thousands of online transactions, so high throughput, fast random access to accounts (hashed or indexed organization), strong security, protection from failure (backup and recovery) and minimal reorganization (24/7 service) are most important.
Q3 – Little Hampton Air Company (3+12)
(a) Entities: AIRCRAFT (supertype) with subtypes FIXED_WING and ROTARY_WING, PILOT, CREW_CHIEF, and FLIGHT (the flight log, an associative entity between pilot and aircraft).
(b) ER diagram:
- AIRCRAFT (AircraftNumber, SeatingCapacity, AircraftType) — total, disjoint specialization on AircraftType into FIXED_WING (NumberOfEngines) and ROTARY_WING (SpeedOfBlade).
- CREW_CHIEF (EmployeeID, Name) 1 —— Maintains —— M AIRCRAFT. Each aircraft has exactly one crew chief; a crew chief may crew more than one aircraft.
- PILOT (FlyingLicenseNumber, Name) M —— Flies —— N AIRCRAFT, drawn as associative entity FLIGHT (FlightDate, HoursFlown); a pilot can fly different aircraft each day.
- PILOT M —— Qualified for —— N aircraft type (fixed wing / rotary wing), shown as a multivalued attribute QualifiedType on PILOT or as a separate QUALIFICATION entity; it supports the pilot proficiency report.
Q4 – Student report normalization (3+12)
(a) UNF: STUDENT (StudentNo, Name, Address, {MajorNo, MajorName}, {UnitCode, UnitDescription, ExamDate, Grade}) — the braces are repeating groups.
(b) 1NF (remove repeating groups): STUDENT (StudentNo, Name, Address); STUDENT_MAJOR (StudentNo, MajorNo, MajorName); STUDENT_UNIT (StudentNo, UnitCode, UnitDescription, ExamDate, Grade).
2NF (remove partial dependencies — MajorName depends only on MajorNo, UnitDescription only on UnitCode): STUDENT (StudentNo, Name, Address); MAJOR (MajorNo, MajorName); STUDENT_MAJOR (StudentNo, MajorNo); UNIT (UnitCode, UnitDescription); RESULT (StudentNo, UnitCode, ExamDate, Grade).
3NF: no transitive dependencies remain, so the 2NF relations above are already in 3NF.
Q5 – Queries on EMP and DEPT (8×1.5)
-- 1
SELECT ename, sal FROM emp WHERE sal > 2850;
-- 2
SELECT ename, job, hiredate FROM emp
WHERE hiredate BETWEEN DATE '1981-02-20' AND DATE '1981-05-01'
ORDER BY hiredate ASC;
-- 3
SELECT DISTINCT e.job, d.loc
FROM emp e JOIN dept d ON e.deptno = d.deptno
WHERE e.deptno = 30;
-- 4 (the standard EMP table spells this manager BLAKE)
SELECT e.ename
FROM emp e JOIN emp m ON e.mgr = m.empno
WHERE m.ename = 'BLACK';
-- 5
SELECT ename, job, sal FROM emp
WHERE job IN ('CLERK', 'ANALYST') AND sal NOT IN (1000, 3000, 5000);
-- 6
SELECT deptno, job, COUNT(*) AS total
FROM emp WHERE job IN ('CLERK', 'ANALYST')
GROUP BY deptno, job ORDER BY deptno;
-- 7
SELECT e.deptno, e.ename, e.sal FROM emp e
WHERE e.sal = (SELECT MIN(sal) FROM emp WHERE deptno = e.deptno)
OR e.sal = (SELECT MAX(sal) FROM emp WHERE deptno = e.deptno)
ORDER BY e.deptno, e.sal;8. The error is “not a single-group group function” (ORA-00937). deptno is a normal column while COUNT(ename) is an aggregate, so Oracle does not know how to group the rows. Fix: SELECT deptno, COUNT(ename) FROM emp GROUP BY deptno;
Q6 – Hotel and Room (4+3+1)
CREATE TABLE Hotel (
Hotel_No CHAR(4) PRIMARY KEY,
Name VARCHAR2(30) NOT NULL,
Address VARCHAR2(60)
);
CREATE TABLE Room (
Room_No NUMBER(4),
Hotel_No CHAR(4) REFERENCES Hotel(Hotel_No),
Type CHAR(1) CHECK (Type IN ('S', 'D', 'F')),
Price NUMBER(7,2) CHECK (Price > 0),
PRIMARY KEY (Room_No, Hotel_No)
);
INSERT INTO Hotel VALUES ('H101', 'Grand Hotel', 'Club Road, Sargodha');
INSERT INTO Hotel VALUES ('H102', 'City Inn', 'University Road, Sargodha');
INSERT INTO Room VALUES (1, 'H101', 'S', 4500);
INSERT INTO Room VALUES (2, 'H101', 'D', 7000);
DELETE FROM Hotel WHERE Hotel_No = 'H101';3. Because rooms still reference hotel H101, the delete fails with a referential integrity error: ORA-02292: integrity constraint violated – child record found. Deleting H102 (no rooms) would succeed. If the foreign key were created with ON DELETE CASCADE, the hotel and its rooms would be deleted together.
