UNIVERSITY OF THE PUNJAB
B.S. 4-Year Program – Fourth Semester (Spring 2023)
Paper: Database Systems Course Code: CC-215 Time: 3 HoursMarks: 60
THE ANSWERS MUST BE ATTEMPTED ON THE ANSWER SHEET PROVIDED
Q.1. Answer the following short questions: (6x5 = 30)
1. Explain Transaction and ACID properties of a transaction.
Transaction: A set of database operations executed as a single unit that must either fully
succeed or fully fail.
ACID Properties:
● Atomicity: All operations in a transaction are completed, or none are.
● Consistency: The database moves from one valid state to another, maintaining all rules.
● Isolation: Transactions run independently without affecting each other.
● Durability: Once committed, changes are permanent even if the system crashes.
2. Define and differentiate Consistency, Redundancy, and Normalization.
● Consistency: Ensures data follows all integrity rules and constraints at all times.
● Redundancy: Having duplicate or repeated data, which wastes space and can cause
inconsistencies.
● Normalization: The process of organizing data to reduce redundancy and improve
integrity by dividing tables and defining relationships.
3. Explain Relational Database.
A database that stores data in tables (relations) with rows and columns, where tables are
linked using keys, enabling efficient data retrieval and management using SQL.
4. What is a Candidate Key? Mention two of its properties.
A candidate key is a minimal set of attributes that can uniquely identify each record in a
table.
● Uniqueness: No two rows have the same key value.
● Minimality: The key contains no unnecessary attributes.
5. Explain ANSI/SPARC Three-Level Architecture.
6. Internal Level: How data is physically stored (file structures, indexes).
7. Conceptual Level: The logical design of the entire database (entities, relationships).
8. External Level: Different user views of the data tailored to their needs.
Answer the following questions:
Q2-Draw an ER diagram according to the following requirements:
A salesperson may manage many other salespeople. Each
salesperson is managed by only one other salesperson.A salesperson
can be an agent for many customers. Each customer is managed by
one salesperson.A customer can place many orders. Each order is
placed by one [Link] order lists many inventory items. An
inventory item may be listed on many [Link] inventory item is
assembled from many parts. A part may be used in many inventory
[Link] employees assemble inventory items from parts.A
supplier supplies many parts. A part may be supplied by many
suppliers.
Reference…
Q.3 Explain first three forms of Normalization (Marks 08)
What is 1NF 2NF and 3NF?
1NF, 2NF, and 3NF are the first three types of database normalization. They
stand for first normal form, second normal form, and third normal form,
respectively.
There are also 4NF (fourth normal form) and 5NF (fifth normal form). There’s
even 6NF (sixth normal form), but the commonest normal form you’ll see out
there is 3NF (third normal form).
All the types of database normalization are cumulative – meaning each one
builds on top of those beneath it. So all the concepts in 1NF also carry over to
2NF, and so on.
The First Normal Form – 1NF
For a table to be in the first normal form, it must meet the following criteria:
● a single cell must not hold more than one value (atomicity)
● there must be a primary key for identification
● no duplicated rows or columns
● each column must have only one value for each row in the table
The Second Normal Form – 2NF
The 1NF only eliminates repeating groups, not redundancy. That’s why there is
2NF.
A table is said to be in 2NF if it meets the following criteria:
● it’s already in 1NF
● has no partial dependency. That is, all non-key attributes are fully
dependent on a primary key.
The Third Normal Form – 3NF
When a table is in 2NF, it eliminates repeating groups and redundancy, but it
does not eliminate transitive partial dependency.
This means a non-prime attribute (an attribute that is not part of the candidate’s
key) is dependent on another non-prime attribute. This is what the third normal
form (3NF) eliminates.
So, for a table to be in 3NF, it must:
● be in 2NF
● have no transitive partial dependency.
Reference…
ENo Ename Title Hiredate
Q.4 Write SQL statements: (Marks 15)
E1 John Elec. Eng 22-11-1990
ASG Employee
E2 Smith Syst. Anal. 27-06-1990
ENo Pno Resp. Dur.
E3 Loo Mech. Eng. 15-12-1990
E1 P1 Manager 12
E4 Michel Programmer 30-05-1990
E2 P1 Analyst 24
E5 Miller Syst. Anal. 11-02-1991
E2 P2 Analyst 24
E6 Davis Elec. Eng 07-02-1993
E7 Jones Mech. Eng. 17-05-1994
E8 Cathey Syst. Anal. 27-02-1991
E3 P3 Consultant 24
E3 P4 Engineer 16
E4 P2 Programmer 18
E5 P2 Manager 10
E6 P4 Engineer 36
E7 P1 Engineer 16
E8 P2 Manager 8
Salaries
PROJ
Title Sal
Elec. Eng 40000 Pno Pname Budget
Syst. Anal. 34000 P1 Instrumentation 150000
Mech. Eng. 27000 P2 Database Prog. 135000
Programmer 24000 P3 CAD/CAM 250000
P4 Maintenance 100000
Write SQL statements for the following:
1. Show the salary of Programmers working on the Instrumentation project. (10)
SELECT [Link] FROM Employee E JOIN Salaries S ON [Link] = [Link]
-- Join Employee with Salaries on Desig JOIN ASG A ON [Link] =
[Link] JOIN PROJ P ON [Link] = [Link] WHERE [Link] =
'Programmer' AND [Link] = 'Instrumentation';
2. Display all records from the ASG table that do not appear in an equi-join with
EMP and PROJ. (5)
SELECT A.*
FROM ASG A
LEFT JOIN Employee E ON [Link] = [Link]
LEFT JOIN PROJ P ON [Link] = [Link]
WHERE [Link] IS NULL OR [Link] IS NULL;
Expected Output:
Eno Pno Resp
Enginee
E6 P5
r
This record from the ASG table does not have a corresponding Pno ('P5') in the PROJ table, thus
it will appear in the result.
3. Show the name and hire date (format: 24 December 1999) of employees
whose salary is: (5)
○ Greater than that of a Manager,
○ Less than that of a Consultant,
○ Not equal to that of a Programmer.
SELECT
[Link],
CONCAT(
DATE_FORMAT([Link], '%d'),
CASE
WHEN DAY([Link]) IN (1, 21, 31) THEN 'st'
WHEN DAY([Link]) IN (2, 22) THEN 'nd'
WHEN DAY([Link]) IN (3, 23) THEN 'rd'
ELSE 'th'
END,
' ',
DATE_FORMAT([Link], '%M %Y')
) AS FormattedHireDate
FROM Employee E
JOIN Salaries S ON [Link] = [Link]
WHERE [Link] > (SELECT MAX(Sal) FROM Salaries WHERE Desig = 'Manager')
AND [Link] < (SELECT MIN(Sal) FROM Salaries WHERE Desig = 'Consultant')
AND [Link] <> (SELECT Sal FROM Salaries WHERE Desig = 'Programmer');
Given the data, this query might return an empty set.
4. Display the total salary (i.e., salary + bonus) of all employees, formatted as:
(40000+3000=43000) with heading Total Salary. (5)
SELECT Expected Output:
CONCAT(
CAST([Link] AS CHAR),
'+',
CAST([Link] AS CHAR),
'=',
CAST(([Link] + [Link]) AS CHAR)
) AS "Total Salary"
FROM Salaries S;
5. Show names of employees who were hired before 1995 and whose names
contain letters A and F. Also, display the substring of their name from A to F.
(Hint: Use nested single-row functions)
SELECT
[Link],
-- The substring logic would need clarification if it's 'A' to 'F' within the name
-- regardless of order or presence of both.
CASE
WHEN [Link] LIKE '%A%' AND [Link] LIKE '%F%' THEN
SUBSTRING([Link], LOCATE('A', [Link]), LOCATE('F', [Link]) - LOCATE('A',
[Link]) + 1)
WHEN [Link] LIKE '%A%' THEN SUBSTRING([Link], LOCATE('A',
[Link]), 1) -- Or some other logic
WHEN [Link] LIKE '%F%' THEN SUBSTRING([Link], LOCATE('F',
[Link]), 1) -- Or some other logic
ELSE NULL
END AS Substring_AF
FROM Employee E
WHERE YEAR([Link]) < 1995
AND ([Link] LIKE '%A%' OR [Link] LIKE '%F%');
With the "AND" condition, the result is empty.
UNIVERSITY OF THE PUNJAB
B.S. 4-Year Program – Fourth Semester (Fall 2023)
Paper: Database Systems Course Code: CC-215 Time: 3 Hours Marks: 60
THE ANSWERS MUST BE ATTEMPTED ON THE ANSWER SHEET PROVIDED
Q.1. Answer the following short questions:(6x5=30)
a) Briefly discuss the different integrity constraints used in relational databases.
Integrity constraints ensure data accuracy and consistency.
● Primary Key ensures each row is uniquely identified.
● Foreign Key maintains referential integrity between tables.
● Not Null, Unique, and Check constraints prevent invalid data entries.
b) What is data dependence? What are its disadvantages?
Data dependence means program logic is tied to the data format.
If data structure changes, all dependent programs must also change.
It reduces flexibility and increases maintenance effort.
This limits scalability and hinders efficient data management.
c) What is a composite key and what is the concept of minimality? Explain with an
appropriate example.
A composite key is a primary key made from two or more columns.
Minimality means no subset of the key can uniquely identify rows.
For example, in a Course_Enrollment(student_id, course_id), both fields
form a composite key.
Neither student_id nor course_id alone is sufficient to identify a row.
d) What are the ACID properties of a transaction?
Atomicity: All operations in a transaction are completed or none.
Consistency: Maintains data integrity before and after a transaction.
Isolation: Concurrent transactions do not interfere with each other.
Durability: Once committed, changes remain even after a crash.
e) Briefly explain Two-Phase Locking (2PL) in concurrent transactions.
2PL is a concurrency control method that prevents conflicts.
It has two phases: Growing phase (acquire locks) and Shrinking phase (release
locks).
No locks are acquired after releasing begins.
It ensures serializability but may cause deadlocks.
f) Briefly explain DDL, DML, and DCL SQL statements with one example each.
DDL (Data Definition Language) defines structure (e.g., CREATE TABLE
students(...)).
DML (Data Manipulation Language) modifies data (e.g., INSERT INTO
students VALUES (...)).
DCL (Data Control Language) controls access (e.g., GRANT SELECT ON
students TO user1).
Answer the following questions:
Q2- Identify entities and draw ER Diagram for the following situation. (3x10=30)
● The firm has a number of sales offices in several states. Attributes of sales office include Office
Number (identifier) and Location.
● Each sales office is assigned one or more employees. Attributes of employee include Employee
ID (identifier) and Employee Name. An employee must be assigned to only one sales office.
● For each sales office, there is always one employee assigned to manage that office. An employee
may manage only the sales office to which he or she is assigned.
● The firm lists property for sale. Attributes of property include Property ID (identifier) and Location.
Components of Location include Address, City, State, and Zip Code.
● Each unit of property must be listed with one (and only one) of the sales offices. A sales office may
have any number of properties listed or may have no properties listed.
● Each unit of property has one or more owners. Attributes of owners are Owner ID (identifier) and
Owner Name. An owner may own one or more units of property. An attribute of the relationship
between property and owner is Percent Owned.
Reference…
Q.3 Normalize the following Patient Medication Form up to 3NF. You must specify the
definition, functional dependencies and anomalies at each stage.
VisitNo VisitDate PatNo PatAge PatCity Diagnosis PhyNo PhySpecialty
V10020 1/13/2023 P1 35 LAHORE EAR INFECTION D1 INTERNIST
V10020 1/13/2023 P1 35 LAHORE D2 INTERNIST
V93030 1/20/2023 P3 17 SIALKOT INFLUENZA D2 NURSE PRACTITIONER
V82110 1/18/2023 P2 60 KASUR PREGNANCY D3 CARDIOLOGIST
As every table has atomic values, it is already in 1st first normal form.
For 2NF alldependencies).
(no partial non-key attributes should
So let’s be fully itfunctionally dependent on the whole primary key
decompose
Visits:
Visit No VisitDate PatNo Diagnosis
V10020 1/13/2023 P1 EAR INFECTION
V93030 1/20/2023 P3 INFLUENZA
V93030 1/18/2023 P2 PREGNANCY
Patient:
PatNo PatAge PatCity PatNo
P1 35 LAHORE P1
P3 17 SIALKOT P3
P2 60 KASUR P2
Visit_pshysician: VisitNo PhyNo
PHYSICIAN:
V10020 D1
PhyNo PhySpecialty
V10020 D2
D1 INTERNIST
V93030 D2
D2 NURSE PRACTITIONER
V82110 D3
D3 CARDIOLOGIST
Q.4 Write SQL queries using the following set of relations
(tables):
EMP(EMPNO, ENAME, JOB, SAL, HIREDATE, COMM, MGR, DEPTNO)
DEPT(DEPTNO, DNAME, LOC)
1. List EMPNO, ENAME, JOB, SAL, and DNAME of all employees hired in the last 5
years.
SELECT [Link], [Link], [Link], [Link], [Link]
FROM EMP e
JOIN DEPT d ON [Link] = [Link]
WHERE [Link] >= ADDDATE(CURDATE(), INTERVAL -5 YEAR);
2. Show ENAME and COMM (display "No Commission" if COMM is NULL) for
employees working in the Accounting or Sales departments.
SELECT [Link],
COALESCE(CAST([Link] AS CHAR), 'No Commission') AS COMM
FROM EMP e
JOIN DEPT d ON [Link] = [Link]
WHERE [Link] IN ('Accounting', 'Sales');
3. Find the name of the most senior employee (earliest HIREDATE).
SELECT [Link],
COALESCE(CAST([Link] AS CHAR), 'No Commission') AS COMM
FROM EMP e
JOIN DEPT d ON [Link] = [Link]
WHERE [Link] IN ('Accounting', 'Sales');
4. Display a list of all employees with an identifier (code) composed of the first two
characters of their JOB and the year of their HIREDATE.
SELECT ENAME,
CONCAT(LEFT(JOB, 2), YEAR(HIREDATE)) AS Code
FROM EMP;
5. Display department-wise count of employees and average salary.
SELECT [Link], COUNT([Link]) AS EmpCount, AVG([Link]) AS AvgSalary
FROM DEPT d
LEFT JOIN EMP e ON [Link] = [Link]
GROUP BY [Link];
UNIVERSITY OF THE PUNJAB
B.S. in Computer Science – Fifth Semester Fall 2024
Paper: Database Systems Course Code: CC-215 Time: 3 HoursMarks: 60
THE ANSWERS MUST BE ATTEMPTED ON THE ANSWER SHEET PROVIDED
Q.1 Short Answer Questions (6 × 5 = 30)
a) Define data and metadata. Explain the difference between data and
information with an example.
Data is a set of raw facts that help identify useful information when they are
cleaned, processed, and organized. Metadata, on the other hand, is data
about data. If data is the new oil, metadata is the refinery. Without metadata,
there is no way to understand or use the data in hand.
b) What is data inconsistency? Discuss its causes and disadvantages.
When the same data exists in different formats in multiple tables. This condition is
known as Data Inconsistency. It means that different files contain different information
about a particular object or person. This can cause unreliable and meaningless
information. Data Redundancy leads to Data Inconsistency.
Problems with Data Inconsistency
Unreliable Information: Data inconsistency can result in conflicting information across
different parts of the database, making it difficult to ascertain the truth.
Difficulties in Data Retrieval: Retrieving data from inconsistent records can be
challenging as you may encounter contradictory data.
Challenges in Decision Making: Inconsistent data can hinder accurate decision
making, especially when businesses rely on updated information.
c) Explain candidate keys, primary key, and secondary keys with examples.
Candidate Keys:
These are all the possible fields (or combinations) that can uniquely identify a row in a table.
Example: In a students table, both student_id and email could be candidate keys.
Primary Key:
One candidate key selected as the main unique identifier for records.
Example: student_id is often chosen as the primary key.
Secondary Keys:
These are non-primary keys used for searching or querying the table efficiently.
Example: email or phone_number used to look up students.
d) What is a data model? Describe different types of data models.
Data Model gives us an idea that how the final system will look like after its
complete implementation. It defines the data elements and the relationships
between the data elements. Data Models are used to show how data is stored,
connected, accessed and updated in the database management system.
Reference….
e) What is the use of locking in concurrent transactions? Explain the levels of lock granularity.
Locking in concurrent transactions ensures data consistency and prevents
interference between transactions. It works by allowing a transaction to reserve a
data item for its exclusive use, preventing other transactions from accessing it until
the lock is released. Lock granularity refers to the size of the data item being
locked, ranging from a single field to the entire database.
Levels of Lock Granularity:
Database-level locking:
The entire database is locked, restricting access to all data by other transactions. This
provides the highest level of isolation but also the lowest level of concurrency.
Table-level locking:
An entire table is locked, preventing other transactions from accessing any part of the
table. This provides a good balance between isolation and concurrency.
Page-level locking:
Specific pages within a table are locked, allowing concurrent transactions to access
different pages of the same table.
Row-level locking:
Individual rows within a table are locked, providing the finest granularity of concurrency
control. This allows concurrent transactions to update different rows of the same table.
Field-level locking:
Individual fields within a row are locked, providing the most granular concurrency
control.
f) What is a JOIN operation in SQL? Describe different types of joins with examples.
Q2. Answer the following questions. (3x10=30)
Draw an ER diagram for a Car Dealership System based on the following scenario:
The dealership sells both new and used cars and operates a service facility.A salesperson may sell
many cars, but each car is sold by only one salesperson.A customer may buy many cars, but each car
is bought by only one customer.A salesperson issues an invoice to a customer for each car sold.A
customer can bring a car in for service without having purchased a car.A service ticket is issued per car
[Link] system maintains service history for each car using its serial number.
A car can be serviced by multiple mechanics, and each mechanic can service many cars.
Reference…
Q.3 Normalization (10 Marks)
Define Normalization and Functional Dependency. Then normalize
the following Property Rental System table step-by-step up to 3rd
Normal Form (3NF). For each normal form, specify its definition and
list the set of relations obtained.
Unnormalized Data:
PropID Date Account Type Amount Balance CustID CustName PropertyID PropertyType
101 1/3/2023 Accounts 2000 12000 251 Nazir Sons 3 Partnership
101 1/3/2023 Accounts 1500 15000 251 Nazir Sons 10 Partnership
104 2/18/2023 Accounts 2000 16000 257 Wow Services 4 Rood
102 2/25/2023 Personal 1200 7200 102 Zafar Assoc 6 Taxation
102 2/25/2023 Personal 2500 20000 102 Zafar Assoc 5 Taxation
Normalization:Normalization is the process of organizing data in a database to minimize
redundancy and dependency. It involves dividing large tables into smaller tables and linking
them through relationships.
Functional Dependency: Functional dependency is a relationship between attributes where
one attribute determines the value of another. It's denoted as A → B, meaning "A
functionally determines B".
Unnormalized Data:
PropID Date Account Type Amount Balance CustID CustName PropertyID PropertyType
101 1/3/2023 Accounts 2000 12000 251 Nazir Sons 3 Partnership
101 1/3/2023 Accounts 1500 15000 251 Nazir Sons 10 Partnership
104 2/18/2023 Accounts 2000 16000 257 Wow Services 4 Rood
102 2/25/2023 Personal 1200 7200 102 Zafar Assoc 6 Taxation
102 2/25/2023 Personal 2500 20000 102 Zafar Assoc 5 Taxation
Q.4 SQL Queries (10 Marks)
Consider the following database tables to write the SQL statements
EMP (EMPNO, ENAME, JOB, SAL, HIREDATE, DEPTNO)
DEPT (DEPTNO, DNAME, LOC)
a) Create EMP table with the following constraints: (4)
Attribute Description
EMPNO Primary Key
ENAME Not Null
JOB “Programmer”,”DBA” Or “Analyst”
SAL Between 25000 and 15000
HIREDATE Default is sysdate
DEPTNO Foriegn key Reference DEPT
CREATE TABLE EMP (
EMPNO INT PRIMARY KEY,
ENAME VARCHAR(50) NOT NULL,
JOB ENUM('Programmer', 'DBA', 'Analyst'),
SAL INT CHECK (SAL BETWEEN 15000 AND 25000),
HIREDATE DATE DEFAULT CURRENT_DATE,
DEPTNO INT,
FOREIGN KEY (DEPTNO) REFERENCES DEPT(DEPTNO)
);
b) Display a list of all employees with an identifier code composed of the first two letters of their
JOB and the year of their HIREDATE. (2)
SELECT ENAME, CONCAT(LEFT(JOB, 2),
YEAR(HIREDATE)) AS Identifier_Code
FROM EMP;
c) List each department’s DEPTNO, total number of employees, and average salary. (2)
SELECT DEPTNO, COUNT(*) AS Total_Employees,
AVG(SAL) AS Average_Salary
FROM
EMP
GROUP BY DEPTNO;
d) List EMPNO, ENAME, DNAME, SAL, and year of hiring for all
employees whose JOB is ANALYST. Sort the result in descending order
of SAL. (2)
SELECT [Link], [Link], [Link], [Link], YEAR([Link])
AS Year_Of_Hiring
FROM EMP E
JOIN DEPT D ON [Link] = [Link]
WHERE [Link] = 'Analyst'
ORDER BY [Link] DESC;
UNIVERSITY OF THE PUNJAB
B.S. in Computer Science – Fifth Semester Fall 2024
Paper: Database Systems Course Code: CC-215 Time: 3 HoursMarks: 60
THE ANSWERS MUST BE ATTEMPTED ON THE ANSWER SHEET PROVIDED
Q.1: Short Answer Questions (10)
1. Draw the ANSI-SPARC Three-Level Architecture diagram and label all layers.
1. Internal Level: How data is physically stored (file structures, indexes).
2. Conceptual Level: The logical design of the entire database (entities, relationships).
3. External Level: Different user views of the data tailored to their needs.
2. Explain EQUI join, outer join, and self-join with examples.
Reference….
3. Define a Candidate Key and state its two properties.
4. What is Backup and Recovery in database systems? Explain briefly.
In database systems, backup and recovery refer to the processes of creating copies of data (backup) and
restoring data from those copies (recovery) to protect against data loss due to various reasons like
hardware failure, software corruption, or even human error. These processes are essential for maintaining
data integrity, availability, and ensuring business continuity.
Backup:
Backup is the process of creating copies of the database or parts of it, usually on a different storage
device.
These copies are used as a safeguard in case the original data is lost or damaged.
Backups can be full, incremental, differential, or snapshot, and are often scheduled to run automatically at
regular intervals.
Recovery:
Recovery is the process of restoring the database to a previous state using the backup copies.
It involves using the backup copies and applying transaction logs or other data recovery methods to bring
the database up to date.
Recovery can be time-consuming, and may require expertise from a database administrator.
(b) Write SQL statements: (20)
Tables for queries
EMP (EID, ENAME,MGR, SAL, DEPTON, COMM,JOB), DEPT(DEPTNO,DNAME,LOC),
SGRADE(SALGRADE,LOSAL HISAL)
1. Show the ename, dname of all those employees working in accounts department and working as clerk and
having F in there name.
SELECT [Link], [Link]
FROM EMP E
JOIN DEPT D ON [Link] = [Link]
WHERE [Link] = 'Accounts'
AND [Link] = 'CLERK'
AND [Link] LIKE '%F%';
2. Show the ename and salgrade of all employees work as manager or clerk and getting salary more than
smith.
SELECT [Link], [Link]
FROM EMP E JOIN SGRADE S ON [Link] BETWEEN [Link] AND [Link]
WHERE [Link] IN ('MANAGER', 'CLERK')
AND
[Link] > ( SELECT SAL FROM EMP WHERE ENAME = 'SMITH' );
3. Show the name, grade and salary of all managers and clerks working in New York or Karachi.
SELECT [Link], [Link], [Link]
FROM EMP E
JOIN DEPT D ON [Link] = [Link]
JOIN SGRADE S ON [Link] BETWEEN [Link] AND [Link]
WHERE [Link] IN ('MANAGER', 'CLERK')
AND [Link] IN ('New York', 'Karachi');
4. Show department name of those departments whose Avg sal is less than tha max salary of all departments.
SELECT [Link]
FROM DEPT D
JOIN EMP E ON [Link] = [Link]
GROUP BY [Link]
HAVING AVG([Link]) < ( SELECT MAX(SAL) FROM EMP );
Q.2. Answer the following questions.
1: Design an ER diagram based on the following scenario: (5 Marks)
Each Contractor has exactly one [Link] contractors can have the same
specialty.A contractor can provide the same specialty on multiple projects.A Project can
use many specialties, and a specialty can be used in many [Link] Project–
Specialty pair must be supported by at least two contractors.
2: Draw an ER-Diagram according to given requirements.(Marks 05)
A Salesperson
only may manage
one.A Salesperson many
can act as other salespeople,
an agent for many but is managed by
Customers.A
Customer is managed by one salesperson and can place many
[Link] Order is placed by one customer and includes multiple
Inventory [Link] Inventory Item may appear in many orders and is
assembled from many [Link] Part may be part of many inventory
[Link] assemble inventory items using many parts.A Supplier
provides many parts, and a Part can be supplied by multiple suppliers.
3: Normalize the following relation R
R= (Student ID, Last Name, First Name, Course ID, Course Section,
Course Name, Grade, Professor Last Name, Professor First Name, Professor
Office #, Professor Qualification)
Students: Courses:
Field Name Description
StudentID (PK)Unique student ID Field Name Description
FirstName Student’s
name first CourseID (PK)Unique course code
LastName Student’s
name last
CourseName Full name of the
course
Professors: CourseSections:
Field Name Description
ProfessorID
(PK) Unique professor ID Field Name Description
FirstName Professor’s first name
LastName Professor’s last name
Office Office number EnrollmentID Unique record for enrollment
Qualification Academic qualification
(PK)
StudentID (FK) Refers to Students(StudentID)
SectionID (FK) Refers to
CourseSections(SectionID)
Grade Grade earned in the course
section
4: What is transaction? Explain ACID properties of transaction. (Marks 05)
Transaction: A set of database operations executed as a single unit that must either fully
succeed or fully fail.
ACID Properties:
● Atomicity: All operations in a transaction are completed, or none are.
● Consistency: The database moves from one valid state to another, maintaining all rules.
● Isolation: Transactions run independently without affecting each other.
● Durability: Once committed, changes are permanent even if the system crashes.
5: Explain any three database objects. (Marks 05)
1. Table
A table is the fundamental object in a database used to store data in
rows and columns.
● Each row (record) represents one item of data.
● Each column (field) holds a specific type of data (e.g., name,
age, salary).
● Tables can have primary keys, foreign keys, and constraints
to maintain data integrity.
2. View
A view is a virtual table based on the result of an SQL query.
● It does not store data physically but shows data from one or
more tables.
● Views are used to simplify complex queries, restrict access to
specific data, or present data differently.
3. Index
An index is a database object that improves the speed of data
retrieval.
● It works like a book index — allowing fast lookup of rows based
on specific columns.
● Indexes can be created on one or more columns.
● While indexes speed up reads, they may slow down inserts
and updates.