Final Explanation
Final Explanation
concepts and break down the topics covered in the files. Here's a structured overview based on
the content of the documents on Relational Algebra and Normalization.
Types of Operations:
1. SELECT (σ)
o Filters rows based on conditions.
o Example: σ DNO=4 (EMPLOYEE) retrieves employees from
department 4.
o Properties:
Commutative: σ(cond1)(σ(cond2)(R)) = σ(cond2)(σ(cond1)(R))
Can be cascaded.
2. PROJECT (π)
o Selects specific columns (attributes).
o Example: π LNAME, FNAME, SALARY (EMPLOYEE)
o Properties:
Removes duplicates.
Not commutative.
3. RENAME (ρ)
o Renames relation or attributes for clarity.
o Example: ρ EmpNames (FNAME, LNAME) (EMPLOYEE)
1. UNION (∪)
o Combines tuples from two relations (eliminates duplicates).
o Both relations must be union-compatible (same attributes and
types).
o Example: RESULT1 ∪ RESULT2
2. INTERSECTION (∩)
o Returns tuples common to both relations.
o Example: EMPLOYEE ∩ MANAGER
1. JOIN
o Combines related tuples from different relations based on a
condition.
o Types:
Inner Join
Outer Join (Left, Right, Full)
o Example: EMPLOYEE ⨝ DNO=DEPT_NO DEPARTMENT
2. DIVISION
o Used for queries involving "for all" conditions.
o Example: Find employees who have worked on all projects.
d) Additional Operations:
2. Outer Union
o Combines relations with different attributes while preserving
unmatched tuples.
e) Relational Algebra Expressions
Normalization Process:
2. Steps in Normalization:
o First Normal Form (1NF):
Eliminate repeating groups; ensure atomicity.
No multi-valued or composite attributes.
Example: Converting a list of phone numbers into separate
rows.
1. Insertion Anomaly:
o Cannot insert a new department without an employee.
2. Deletion Anomaly:
o Deleting an employee may remove critical project data.
3. Modification Anomaly:
o Updating a budget requires changes in multiple rows.
Exercises to Practice:
1. Given relation:
STUDENT (Student#, Module#, S_name, Age, Address, M_title, Inst_code,
Inst_name, Sem, Grade)
Functional dependencies:
Steps:
1. Understand Concepts:
o Practice identifying SELECT, PROJECT, JOIN operations in
relational algebra.
o Review normalization by working on sample tables.
Would you like specific explanations on any topic or assistance with practice questions?
Ch 7
1. Normalization Overview
Normalization is a process in database design that organizes data to:
Anomalies to Avoid:
1. Insertion Anomaly:
2. Deletion Anomaly:
3. Modification Anomaly:
Definition:
Examples of FDs:
1. Reflexivity: If Y ⊆ X, then X → Y
2. Augmentation: If X → Y, then XZ → YZ
Criteria:
Example Violation:
Solution:
Criteria:
Relation is in 1NF.
Example Violation:
Solution:
Criteria:
Relation is in 2NF.
Example Violation:
Solution:
Criteria:
Relation is in 3NF.
Solution:
5. Decomposition Process
3. Inst_code → Inst_name
Relations:
STUDENT (Student#, S_name, Age)
Relations:
2. Master Anomalies:
Try normalizing datasets from your course projects or sample business cases.
Would you like a quiz or practice exercises to test your understanding?
Ch 6
Example:
The primary key is a combination of the foreign key and the weak entity’s
partial key.
Example:
Owner: EMPLOYEE(SSN)
Mapped to: DEPENDENT(ESSN FOREIGN KEY, Dependent_Name PRIMARY
KEY, Relationship)
Possible approaches:
Example:
Mapped to:
Add the primary key of the “1” side as a foreign key in the “N” side table.
Example:
Mapped to:
WORKS_ON(
Hours,
Include the primary key of the entity that owns the attribute as a foreign key.
The combination of the attribute and foreign key forms the primary key.
Example:
Attribute: DEPARTMENT(LOCATIONS)
Mapped to:
DEPT_LOCATIONS(
Example:
Mapped to:
SUPPLY(
Quantity,
Create separate tables for each subclass, containing the primary key of the
superclass.
Create one table with an additional attribute to identify the subclass type.
Example:
Example:
ER Schema Example:
Mapping Steps:
Ch 5
Informal Definitions:
Example Table:
Relation name: R
Characteristics of Relations:
1. Ordering of Tuples:
No specific order (rows are unordered in a relation).
2. Ordering of Attributes:
3. Atomicity:
4. Uniqueness:
5. Domain Constraint:
Types of Constraints:
1. Key Constraints:
2. Entity Integrity:
3. Referential Integrity:
Ensures valid relationships between tables using foreign keys.
4. Semantic Integrity:
Business rules that cannot be expressed directly in the relational model (e.g.,
“an employee cannot work more than 40 hours per week”).
Key Constraints:
1. Super Key:
Example: {SSN}
An attribute in one relation that refers to the primary key of another relation.
A foreign key must refer to an existing primary key in the referenced table or
be NULL.
Example:
| 101 | Alice | 10 |
3. Domain Constraints:
Ensures attribute values fall within the specified domain (e.g., age should be
positive integers).
4. Relational Model Operations
1. Retrieval Operations:
2. Update Operations:
Operations include:
Handling Violations:
2. Memorize Constraints:
Know the rules for primary keys, foreign keys, and referential integrity.
3. Practice Operations:
Writing queries to retrieve and manipulate data.
4. Recognize Violations:
Identify when integrity constraints are violated and how to resolve them.
Ch 4
Definition:
The general entity type is called the superclass, and its sub-groupings are
subclasses.
Example:
EMPLOYEE can have subclasses like:
Key Characteristics:
IS-A Relationships:
Inheritance:
Rules:
3. Specialization
Definition:
Examples:
Specialization Characteristics:
Specific Attributes:
Subclasses can have their own unique attributes (e.g., TypingSpeed for
SECRETARY).
Participation in Relationships:
4. Generalization
Definition:
Example:
5. Attribute Inheritance
Example:
If EMPLOYEE has attributes {Name, SSN, Address}, its subclass SECRETARY
will inherit these attributes along with any additional attributes like
{TypingSpeed}.
Types of Constraints:
Definition:
Example:
Characteristics:
Can have overlapping attributes from multiple entities.
Some database modeling tools represent EER diagrams using UML notation.
Example:
UML notation for EMPLOYEE and its subclasses using inheritance arrows.
3. Differentiate Constraints:
Ch 3
1. System Definition:
2. Database Design:
3. Database Implementation:
5. Application Conversion:
Adapt applications to the new database system.
7. Operation:
Key Characteristics:
3. ER Model Components
Entities:
Entity Representation:
Attributes:
1. Simple Attributes:
2. Composite Attributes:
3. Single-Valued Attributes:
Example: Age.
4. Multivalued Attributes:
Multiple values for an entity.
Example: {PhoneNumbers}.
5. Derived Attributes:
Notation:
Key Attributes:
Types of Keys:
1. Primary Key:
2. Composite Key:
Notation:
3. Relationships in ER Model
A relationship connects two or more entities with specific meaning.
Examples:
Notation:
4. Relationship Constraints
Cardinality Ratios:
Notation:
Participation Constraints:
Notation:
Key Points:
1. Proper Naming:
Attributes: Capitalized.
2. Avoid Redundancy:
ER models can also be represented using UML class diagrams, which include:
Classes (Entities)
Attributes (Properties)
Associations (Relationships)
10. Exam Preparation Tips
Ch2
2. Network Model:
Supports many-to-many relationships.
2. Data Models
Schema:
Changes infrequently.
Instance (State):
Example:
Instance:
5. Three-Schema Architecture
This architecture separates the database into three layers to provide data
abstraction and independence.
Advantages:
4. Data Independence
Example:
Changing the storage format (e.g., changing from file storage to indexed
storage) without affecting application queries.
Example:
Name VARCHAR(50)
);
Example:
Concurrency control.
1. Centralized Architecture:
All data is stored and processed on a single server.
2. Distributed Architecture:
3. Client-Server Architecture:
The client requests data, and the server processes the request.
5. Multi-User Access:
Ch 1
1. Module Information
Instructor: Dr. Doaa Elzanfaly
Textbook:
2. Assessment Scheme
Project: 50%
Project Deliverables:
Week 3: Proposal
3. Module Objectives
6. Topics Covered
Lectures:
1. Database Concepts
5. Relational Algebra
6. Normalization
Lab:
7. Basic Definitions
1. Data:
2. Database:
4. Database System:
1. Defining a Database:
2. Constructing a Database:
3. Manipulating Data:
4. Concurrent Access:
1. Data Abstraction:
2. Program-Data Independence:
3. Self-Describing Nature:
4. Multi-User Access:
Provides concurrent access to multiple users with consistency.
Components:
Hardware
Software (DBMS)
Data
Procedures
Users
2. Database Designers:
3. End Users:
Considerations:
1. Cost:
3. Special Cases:
b) Data Encryption
d) Multi-User Access
a) Attribute
b) Domain
c) Tuple
d) Schema
Answer: c) Tuple
b) Multi-Valued Dependency
c) Trigger Constraint
d) Check Constraint
6. What does the term ‘degree’ of a relation refer to in the relational model?
a) Number of tuples
b) Number of attributes
c) Number of relationships
a) Rectangle
b) Diamond
c) Oval
d) Double line
Answer: b) Diamond
9. A weak entity set requires which type of relationship with its owner entity?
a) Ternary
b) Binary
c) Identifying
d) Aggregation
Answer: c) Identifying
Section 4: Normalization
a) 1NF
b) 2NF
c) 3NF
d) BCNF
Answer: b) 2NF
Explanation: 2NF ensures that all non-key attributes depend on the entire
primary key, not just part of it.
12. If a relation is in 3NF but not in BCNF, what issue may still exist?
a) Partial dependency
b) Transitive dependency
c) Functional dependency
d) Redundant dependency
13. What SQL command is used to remove all records from a table without
deleting the table structure?
a) DELETE
b) DROP
c) TRUNCATE
d) ALTER
Answer: c) TRUNCATE
Explanation: The TRUNCATE command removes all records but retains the
table structure.
a) GROUP BY
b) WHERE
c) ORDER BY
d) HAVING
Answer: b) WHERE
a) UNIQUE
b) PRIMARY KEY
c) NOT NULL
d) CHECK
a) Isolation
b) Durability
c) Atomicity
d) Consistency
Answer: c) Atomicity
a) CHECK
b) FOREIGN KEY
c) PRIMARY KEY
d) DEFAULT
c) Reduced redundancy
d) Easier maintenance
a) Top-down approach
b) Bottom-up approach
c) Hybrid approach
d) Functional approach
a) Hardware
b) Users
c) Operating System
d) Software
Explanation: The correct syntax retrieves all students where the major is
‘CS’.
Explanation: The SUM function aggregates the total value of the Amount
column.
Explanation: First, the selection operation σ Price > 500 filters rows, then
projection π(Name) selects the Name attribute.
a) EMPLOYEE ⨝ DEPARTMENT
b) Course → Instructor
d) Instructor → Course
Functional dependencies:
ProductName → Quantity
a) 1NF
b) 2NF
c) 3NF
d) BCNF
Answer: a) 1NF
a) Single rectangle
b) Double rectangle
c) Diamond
d) Oval
Would you like more questions or detailed explanations for any specific
topics?
CUSTOMERS Table:
ORDERS Table:
Which SQL query retrieves customer names with orders greater than 250?
a)
SELECT Name FROM CUSTOMERS
WHERE CustID IN (SELECT CustID FROM ORDERS WHERE Amount > 250);
b)
c)
d)
Answer: b)
Explanation: COUNT(*) counts the number of rows that satisfy the given
condition.
15. Which SQL statement correctly removes all rows from the
PRODUCTS table but keeps the table structure?
Explanation: The selection (σ Salary > 50000) filters rows, and projection (π
Name, Department) returns specific columns.
Section 9: Normalization
Explanation: 3NF requires that all non-key attributes depend only on the
primary key, avoiding transitive dependencies.
a) 1NF
b) 2NF
c) 3NF
d) BCNF
Answer: a) 1NF
c) Using a rectangle
d) Using a diamond
a) Atomicity
b) Consistency
c) Isolation
d) Durability
Answer: d) Durability
Explanation: To resolve deadlocks, the DBMS may roll back one of the
conflicting transactions.
a) One-to-Many (1:N)
b) Many-to-Many (M:N)
c) One-to-One (1:1)
d) Unary Relationship
Explanation: Patients can have multiple doctors, and doctors can have
multiple patients, requiring an M:N relationship.
Would you like more practice questions or specific topics explained in detail?
Here are more practical database questions focusing on SQL queries, ERD
diagrams, relational algebra, and critical thinking scenarios.
Section 13: SQL Queries
Which query will return the second highest salary from the table?
a)
b)
SELECT DISTINCT Salary FROM EMPLOYEE ORDER BY Salary DESC LIMIT 1,1;
c)
d)
Answer: c)
Explanation: This query first finds the maximum salary, then retrieves the
next highest value.
27. Consider the ORDERS and CUSTOMERS tables:
ORDERS Table:
CUSTOMERS Table:
Which SQL query retrieves all customers who have not placed an order?
a)
b)
c)
d)
SELECT Name FROM CUSTOMERS
Answer: b)
Explanation: A LEFT JOIN with a WHERE clause filtering NULL values correctly
finds non-matching records.
28. Given the PRODUCTS table, how would you retrieve the top 3
highest-priced products?
|1 | Laptop | 1500 |
|2 | Phone | 1000 |
|3 | TV | 1200 |
|4 | Tablet | 800 |
a)
b)
d)
Answer: a)
a) Partial Dependency
b) Transitive Dependency
c) Repeating Groups
d) No Issue
Answer: b) Transitive Dependency
a) One-to-One (1:1)
b) One-to-Many (1:M)
c) Many-to-Many (M:N)
d) Recursive Relationship
Explanation: A patient can visit multiple doctors, and doctors can attend to
multiple patients, requiring an associative table.
31. Which of the following best represents the primary key in the
relationship below?
b) DeptID
c) (EmpID, DeptID)
d) Hours
32. Given the query below, what index would optimize its
performance?
a) B-Tree Index
b) Hash Index
c) Clustered Index
d) Bitmap Index
Explanation: Bitmap indexes are not efficient for frequently updated tables
due to their static nature.
a) BEGIN;
b) START TRANSACTION;
c) OPEN TRANSACTION;
d) TRANSACTION START;
37. Which of the following best explains why surrogate keys are used
instead of natural keys?
Semester: One
Instructions to Students:
No equipment allowed.
i. Data Dictionary
iv. DML
c) Given relations A(X, Y) with 300 tuples and B(Y, Z) with 400
tuples, estimate the number of tuples for the following relational
operations and justify your answer: [12 marks]
A⋈B
i. Π X(A)
ii.
iii. A ∪ B (assuming compatibility)
iv. Σ Y > 500 (A)
Semester: One
Instructions to Students:
No equipment allowed.
i. Data Dictionary
v. DML
c) Given relations A(X, Y) with 300 tuples and B(Y, Z) with 400
tuples, estimate the number of tuples for the following relational
operations and justify your answer: [12 marks]
A⋈B
i. Π X(A)
A ∪ B (assuming compatibility)
ii.
iii.
iv. Σ Y > 500 (A)
Relationships:
CUSTOMER places multiple ORDERS (1:M)
c) If there are 50 customers, 200 orders, and 500 items, what is the
maximum number of records in the relationship table between
ORDER and ITEM? [6 marks]
Functional Dependencies:
EmpID → EmpName
ProjectID → ProjectName
(EmpID, ProjectID) → HoursWorked
a) Identify the highest normal form the relation satisfies and explain
why. [5 marks]
a)
ii. Foreign Key: A field in one table that uniquely identifies a row in another
table, establishing referential integrity.
b)
ACID properties ensure:
Consistency: Ensures data remains valid before and after the transaction.
c)
a)
Relational Algebra:
SQL Query:
FROM CATEGORY C
GROUP BY C.CategoryName;
c)
---
a)
The diagram shows that customers place orders, and each order contains
multiple items.
b)
Min-max notation:
CUSTOMER places ORDER (1, N)
c)
d)
Relational Schema:
---
a)
c)
Normalized to 3NF:
---
Would you like additional practice exams or specific topics covered in more
detail?
Relationships:
CUSTOMER places multiple ORDERS (1:M)
f) If there are 50 customers, 200 orders, and 500 items, what is the
maximum number of records in the relationship table between
ORDER and ITEM? [6 marks]
Functional Dependencies:
EmpID → EmpName
ProjectID → ProjectName
(EmpID, ProjectID) → HoursWorked
e) Identify the highest normal form the relation satisfies and explain
why. [5 marks]
a)
ii. Foreign Key: A field in one table that uniquely identifies a row in another
table, establishing referential integrity.
b)
ACID properties ensure:
Consistency: Ensures data remains valid before and after the transaction.
c)
a)
Relational Algebra:
SQL Query:
FROM CATEGORY C
GROUP BY C.CategoryName;
c)
a)
The diagram shows that customers place orders, and each order contains
multiple items.
b)
Min-max notation:
CUSTOMER places ORDER (1, N)
c)
d)
Relational Schema:
a)
b)
Update Anomaly: Updating the project name requires multiple updates.
c)
Normalized to 3NF:
Would you like additional practice exams or specific topics covered in more
detail?
b) Discuss the importance of the ACID properties in database transactions and explain how they
ensure data integrity. [7 marks]
c) Determine whether the following statements are TRUE or FALSE with justification. [10
marks]
i. A foreign key in a relational database must always be a primary key in the referenced table.
ii. Functional dependencies are used to determine the normalization of a relation.
iii. SQL is a procedural language.
iv. In relational algebra, the Cartesian product produces a new relation by combining tuples.
v. BCNF ensures that there are no transitive dependencies in the relation.
a) Write a relational algebra expression to retrieve product names and category names for
products priced above 1000. [7 marks]
b) Write an SQL query to retrieve each category name along with the total number of products in
that category. [6 marks]
c) Given relations A(X, Y) with 300 tuples and B(Y, Z) with 400 tuples, estimate the number of
tuples for the following relational operations and justify your answer: [12 marks]
ii. A ⋈ B
i. π X(A)
c) If there are 50 customers, 200 orders, and 500 items, what is the maximum number of records
in the relationship table between ORDER and ITEM? [6 marks]
d) Convert the ER diagram into relational schema including primary and foreign keys. [10
marks]
Functional Dependencies:
EmpID → EmpName
ProjectID → ProjectName
(EmpID, ProjectID) → HoursWorked
a) Identify the highest normal form the relation satisfies and explain why. [5 marks]
b) Give an example of an update and a delete anomaly that may occur in the current relation. [7
marks]
c) Normalize the relation to 3NF and provide the decomposed relations. [8 marks]
a)
i. Data Dictionary: A centralized repository of metadata that provides details about database
schema, structure, and constraints.
ii. Foreign Key: A field in one table that uniquely identifies a row in another table, establishing
referential integrity.
iii. Specialization in EERD: A process of defining a set of sub-entities that inherit common
attributes from a general entity.
iv. DML (Data Manipulation Language): SQL commands used to retrieve and manipulate
data, such as SELECT, INSERT, UPDATE, and DELETE.
b)
ACID properties ensure:
c)
i. FALSE – A foreign key can reference any unique column.
ii. TRUE – Functional dependencies are crucial for normalization.
iii. FALSE – SQL is a declarative language.
iv. TRUE – Cartesian product results in all possible combinations.
v. FALSE – BCNF focuses on eliminating functional dependencies, not transitive dependencies.
a)
Relational Algebra:
b)
SQL Query:
c)
a)
The diagram shows that customers place orders, and each order contains multiple items.
b)
Min-max notation:
c)
Maximum relationship entries: 200 orders × 500 items = 100,000 entries.
d)
Relational Schema:
a)
The relation violates 2NF due to partial dependencies (EmpID → EmpName, ProjectID →
ProjectName).
b)
c)
Normalized to 3NF:
Would you like additional practice exams or specific topics covered in more detail?
Database Systems - Practice Final Exam (Version 2)
b) Explain the role of a database management system (DBMS) in ensuring data integrity and
security. [7 marks]
c) Determine whether the following statements are TRUE or FALSE with justification. [10
marks]
a) Write a relational algebra expression to retrieve the employee names and department names
for employees earning more than 5000. [7 marks]
b) Write an SQL query to find the total salary paid to employees in each department. [6 marks]
c) Consider relations R(A, B) with 150 tuples and S(B, C) with 200 tuples. Estimate the number
of tuples for the following operations and justify your answer: [12 marks]
ii. R ⋈ S
i. π A(R)
Relationships:
ER Diagram:
Relationships:
a) Explain the meaning of the ER diagram based on the given scenario. [6 marks]
c) If there are 30 professors, 100 courses, and 500 students, what is the maximum number of
enrollments in the relationship? [6 marks]
d) Convert the ER diagram to relational schema with primary and foreign keys. [10 marks]
Functional Dependencies:
TransactionID → PurchaseDate
ProductID → ProductName
CustomerID → CustomerName
(TransactionID, ProductID) → PurchaseDate
a) Identify the highest normal form the relation satisfies and explain why. [5 marks]
c) Normalize the relation to 3NF and provide the decomposed relations. [8 marks]
a) Definitions:
Data Security:
2. Data encryption.
FROM EMPLOYEE E
GROUP BY D.DeptName;
Calculation:
Name VARCHAR(50),
Department VARCHAR(50)
);
CREATE TABLE COURSE (
Title VARCHAR(100),
Credits INT
);
Name VARCHAR(50),
Major VARCHAR(50)
);
ProfID INT,
CourseID INT,
);
StudentID INT,
CourseID INT,
The given relation is in 1NF but violates 2NF due to partial dependencies
(ProductID → ProductName, CustomerID → CustomerName).
c) 3NF Decomposition:
Decomposed relations:
CUSTOMER (CustomerID, CustomerName)
SQL Schema:
CustomerName VARCHAR(50)
);
ProductName VARCHAR(50)
);
CustomerID VARCHAR(10),
PurchaseDate DATE,
);
TransactionID VARCHAR(10),
ProductID VARCHAR(10),
);
Semester: One
Instructions to Students:
No equipment allowed.
Question 1: Conceptual Understanding [25 Marks]
i. Composite Key
c) Given relations X(A, B) with 100 tuples and Y(B, C) with 200
tuples, estimate the number of tuples for the following
operations and justify your answer: [12 marks]
X⋈Y
i. Π A(X)
ii.
iii. X ∩ Y (assuming compatibility)
iv. Σ B > 50 (Y)
Relationships:
Functional Dependencies:
CustomerID → CustomerName
ProductID → ProductName
a) Identify the highest normal form the relation satisfies and
explain why. [5 marks]
Model Answers
a) Definitions:
d) True/False:
1. FALSE – A relation can have only one primary key but multiple
candidate keys.
b) SQL Query:
FROM PUBLISHER P
GROUP BY P.PubName;
c) Tuple Estimation:
a) Explanation:
b) Min-Max Notation:
Name VARCHAR(50),
Position VARCHAR(50)
);
Date DATE,
EmpID INT,
);
Name VARCHAR(50),
Price DECIMAL(10,2)
);
TransID INT,
ProdID INT,
Quantity INT,
);
b) Anomalies:
c) 3NF Decomposition:
CUSTOMER(CustomerID, CustomerName)
PRODUCT(ProductID, ProductName)
Semester: One
Instructions to Students:
No equipment allowed.
i. Super Key
v. Referential Integrity
iv. The JOIN operation in SQL combines rows based on a related column.
c) Given relations M(X, Y) with 120 tuples and N(Y, Z) with 150
tuples, estimate the number of tuples for the following
operations and justify your answer: [12 marks]
M⋈N
i. Π X(M)
ii.
iii. M ∩ N (assuming compatibility)
iv. Σ Y > 50 (N)
Functional Dependencies:
CustomerID → CustomerName
ProductID → ProductName
a) Identify the highest normal form the relation satisfies and explain
why. [5 marks]
a) Definitions:
ii. Candidate Key: A minimal super key, meaning no subset can uniquely
identify a row.
iii. Weak Entity: An entity that depends on another entity for identification
and does not have a sufficient unique attribute.
Advantages:
1. Reduces redundancy.
3. Minimizes anomalies.
Disadvantages:
1. Complex queries.
d) True/False:
b) SQL Query:
FROM STUDENT S
GROUP BY D.DeptName;
c) Tuple Estimation:
a) Explanation:
b) Min-Max Notation:
d) Relational Schema:
Name VARCHAR(50),
Specialization VARCHAR(50)
);
Name VARCHAR(50),
Age INT,
Gender CHAR(1)
);
Date DATE,
DoctorID INT,
PatientID INT,
);
Would you like another set of questions?
Semester: One
Instructions to Students:
No equipment allowed.
v. Indexing
iv. A foreign key must always reference a primary key in another table.
c) Given relations P(A, B) with 200 tuples and Q(B, C) with 300
tuples, estimate the number of tuples for the following
operations and justify your answer: [12 marks]
P⋈Q
i. Π A(P)
P ∪ Q (assuming compatibility)
ii.
iii.
iv. Σ B > 100 (P)
Functional Dependencies:
ProductID → ProductName
CustomerID → CustomerName
a) Identify the highest normal form the relation satisfies and explain
why. [5 marks]
a) Definitions:
i. Entity Integrity: Ensures each table has a primary key and no null values in
it.
ii. Outer Join: A join that returns matched records as well as unmatched
records from one or both tables.
b)
Centralized Database:
Distributed Database:
Data distributed across multiple locations.
d) True/False:
b) SQL Query:
FROM EMPLOYEE E
GROUP BY D.DeptName;
c) Tuple Estimation:
a) Explanation:
b) Min-Max Notation:
c) Maximum records:
d) Relational Schema:
Name VARCHAR(50),
Major VARCHAR(50)
);
CREATE TABLE COURSE (
Title VARCHAR(50),
Credits INT,
InstructorID INT,
);
Name VARCHAR(50),
Department VARCHAR(50)
);
StudentID INT,
CourseID INT,
);
Semester: One
Instructions to Students:
i. Foreign Key
ii. Trigger
v. Transaction
b) Describe the advantages of using indexes in a relational database and
mention two types of indexes commonly used. [7 marks]
A⋈B
i. Π P(A)
ii.
iii. A – B (assuming compatibility)
iv. Σ Q > 50 (A)
Relationships:
A BOOK can have multiple AUTHORS (M:N).
Functional Dependencies:
EmpID → EmpName
ProjectID → ProjectName
a) Identify the highest normal form the relation satisfies and explain
why. [5 marks]
a) Definitions:
i. Foreign Key: An attribute in one table that refers to the primary key of
another table to establish relationships.
iii. Cardinality in ERD: Describes the number of instances of one entity that
can be associated with instances of another entity.
b) Advantages of Indexing:
Types:
1. B-Tree Index
2. Hash Index
d) True/False:
1. FALSE – The DELETE statement removes rows, not the table structure
(DROP does this).
b) SQL Query:
FROM ORDERS
GROUP BY CustomerID;
c) Tuple Estimation:
a) Explanation:
A book can have multiple authors, and an author can write multiple books.
b) Min-Max Notation:
d) Relational Schema:
Title VARCHAR(100),
Genre VARCHAR(50),
Price DECIMAL(10,2)
);
Name VARCHAR(100),
Nationality VARCHAR(50)
);
Date DATE,
Quantity INT,
TotalAmount DECIMAL(10,2),
BookID INT,
);
BookID INT,
AuthorID INT,
);
Would you like another exam set?
Semester: One
Instructions to Students:
i. Composite Attribute
v. ACID Properties
b) Compare and contrast static and dynamic SQL. Provide use cases for each.
[7 marks]
c) Given relations R(A, B) with 300 tuples and S(B, C) with 400
tuples, estimate the number of tuples for the following
operations and justify your answer: [12 marks]
R⋈S
i. Π A®
ii.
iii. R ∩ S (assuming compatibility)
iv. Σ B < 100 ®
Relationships:
| Duration |
c) If there are 100 guests, 200 rooms, and 500 bookings, what is
the maximum number of records in the BOOKING table? [6
marks]
Functional Dependencies:
CustID → CustName
ProdID → ProdName
a) Identify the highest normal form the relation satisfies and explain
why. [5 marks]
Model Answers
a) Definitions:
ii. Referential Integrity Constraint: Ensures that a foreign key in one table
references an existing primary key in another table.
b)
Dynamic SQL: SQL statements built and executed at runtime based on user
inputs or conditions.
Use Cases:
d) True/False:
b) SQL Query:
FROM SUPPLIER S
GROUP BY S.Name;
c) Tuple Estimation:
1. Π A® → 300 tuples.
a) Explanation:
The diagram shows that guests can make multiple bookings, and rooms can
be booked multiple times.
b) Min-Max Notation:
c) Maximum records:
d) Relational Schema:
CREATE TABLE GUEST (
Name VARCHAR(50),
ContactNumber VARCHAR(15)
);
RoomType VARCHAR(50),
PricePerNight DECIMAL(10,2)
);
Date DATE,
GuestID INT,
RoomID INT,
Duration INT,
);