Database QB1
Database QB1
Total Marks: 70
Total Duration: 150 minutes
Instructions
PART - A
PART - B
PART - C
Basic Instructions
1. You can freely navigate between different questions forward and backward using
Next and Previous buttons.
2. Finish button will be enabled only towards the end of the exam.
1. Make sure to upload your scans immediately after you answer every question. Do
NOT wait till the end to avoid panic.
2. The exam time is inclusive of time for scanning & uploading answers.
3. If using laptop + mobile for the exam, click on Open Test on the laptop and click on
Scan & Upload on mobile.
4. If using laptop + mobile for the exam, when scanning and uploading from mobile,
ensure that the correct question is open on the laptop.
5. When clicking on the Camera button on a smartphone for scanning and uploading,
you have 2 camera applications available to scan the answer:
o Your phone’s native camera
o An alternative Low Memory Camera
o Click on the Low Memory Camera in case your browser shows an error due
to low memory.
Section: PART A
Marks per question: 1
25 of 25 question(s) in this section will be shown to examinee.
Examinee should answer all 25 question(s) in this section.
DBMS is:
● ○ collection of queries
● ○ high-level language
● ○ programming language
● ● stores, modifies and retrieves data
● ○ Hierarchical
● ○ Network
● ○ Distributed
● ● Decentralized
Which of the following is known as a set of entities of the same type that share same
properties or attributes?
● ○ Relation set
● ● Entity set
● ○ Records
● ○ ER model
● ○ Remove
● ● drop table
● ○ del
● ○ erase
● ○&
● ○.
● ●%
● ○@
● ○ Column
● ○ specialisation
● ○ Generalization
● ● cardinality
● ○ Specialization
● ● Generalization
● ○ Aggregation
● ○ Relation
Which of the following keys is generally used to represent the relationships between the
tables?
● ○ unique
● ○ candidate
● ● Foreign
● ○ primary
Which one of the following keywords is used to find out the number of values in a
column?
● ○ sum
● ○ total
● ● count
● ○ add
In the following Query, which of the following can be placed in the Query's blank
portion to display the salary from highest to lowest amount, and sorting the employee
names alphabetically?
vbnet
Copy code
SELECT * FROM instructor ORDER BY salary ____, name ____;
● ○ ascending, descending
● ● Desc, Asc
● ○ Asc, Desc
● ○ descending, ascending
Q13: Difficulty Level: Very Easy
● ○ sum
● ○ min
● ● select
● ○ max
● ○ define view
● ○ recompile view
● ○ update view
● ● alter view
A list consists of last names, first names, addresses, and pin codes. If all people in the list
have the same last and the same pin code, a useful key would be:
A compound key consisting of the first name and the last name belongs to which normal
form?
● ○ dependent
● ● candidate
● ○ prime
● ○ super
● ● Transitive dependency
● ○ joint dependency
● ○ function dependency
● ○ multi-dependency
● ● minimal
● ○ equal
● ○ like
● ○ maximal
● ○ unique
● ○ primary
● ○ not null
● ● null
● ○ edit
● ○ write
● ○ save
● ● commit
● ●4
● ○5
● ○3
● ○6
Section: PART B
(OR)
b) Explain the following with examples:
i) DDL (2.5)
ii) DML (2.5)
● Key Commands:
o CREATE: To create new database objects (e.g., tables, views).
Example:
sql
Copy code
CREATE TABLE Employee (
EmpID INT PRIMARY KEY,
Name VARCHAR(50),
Salary DECIMAL(10,2)
);
sql
Copy code
ALTER TABLE Employee ADD Department VARCHAR(50);
sql
Copy code
DROP TABLE Employee;
● Key Commands:
o INSERT: To add new records into a table.
Example:
sql
Copy code
INSERT INTO Employee (EmpID, Name, Salary)
VALUES (1, 'John Doe', 50000);
sql
Copy code
UPDATE Employee
SET Salary = 55000
WHERE EmpID = 1;
sql
Copy code
DELETE FROM Employee
WHERE EmpID = 1;
sql
Copy code
SELECT * FROM Employee WHERE Salary > 40000;
a) Write a short note on the E-R Data Model and how it is represented.
The Entity-Relationship (E-R) Data Model is a high-level conceptual model used to describe
the data and relationships within a system. It serves as the foundation for designing relational
databases.
(OR)
b) Write the steps to convert an ER diagram into tables. Explain with an example.
1. Identify Entities:
o Each entity becomes a table.
o Example: Entity Employee becomes a table with attributes as columns
(Emp_ID, Name, Salary).
2. Map Attributes:
o Attributes of entities are represented as columns in the corresponding table.
o Primary keys are selected for each table.
o Example: In the Employee table, Emp_ID is the primary key.
3. Map Relationships:
o One-to-One (1:1): Add the primary key of one entity as a foreign key in the
other.
▪ Example: If Manager has a one-to-one relationship with Department,
add Manager_ID as a foreign key in the Department table.
o One-to-Many (1:N): Add the primary key of the "one" entity as a foreign key
in the "many" entity.
▪ Example: For Works_In relationship, add Dept_ID as a foreign key in
the Employee table.
o Many-to-Many (M:N): Create a new table to represent the relationship,
including foreign keys from both entities.
▪ Example: For Enrolled relationship between Student and Course,
create a new table with Student_ID and Course_ID as foreign keys.
4. Normalize Tables:
o Ensure the tables are normalized to avoid redundancy and maintain data
integrity.
5. Example:
o ER Diagram: Employee and Department connected by Works_In.
▪ Employee(Emp_ID, Name, Salary, Dept_ID)
▪ Department(Dept_ID, Dept_Name)
a) List out the operations of relational algebra with a suitable example (Any five).
(OR)
b) Consider the relational table given below and assess the following SQL queries.
i) List all the employees whose names start with the letter 'L':
sql
Copy code
SELECT * FROM Employee
WHERE Name LIKE 'L%';
This query retrieves all employees where the Name column starts with the letter 'L.'
sql
Copy code
SELECT Dept, MAX(Salary) AS Max_Salary
FROM Employee
GROUP BY Dept;
This query retrieves the highest salary (MAX(Salary)) for each department, grouping results
by the Dept column.
sql
Copy code
SELECT COUNT(*) AS Num_Employees
FROM Employee
WHERE Dept = 'accounts';
This query counts the number of rows in the Employee table where the Dept column is
'accounts.'
Forms of Normalization:
1. First Normal Form (1NF): Removes duplicate columns and ensures atomicity (each
column contains unique and indivisible values).
2. Second Normal Form (2NF): Removes partial dependencies by ensuring all non-key
attributes are fully dependent on the primary key.
3. Third Normal Form (3NF): Eliminates transitive dependencies, ensuring attributes
depend only on the primary key.
4. Boyce-Codd Normal Form (BCNF): Addresses anomalies not handled by 3NF when
non-prime attributes determine other non-prime attributes.
Student_I Na Cour
D me se
Alic
101 Math
e
Alic Scien
101
e ce
(OR)
b) Describe the ACID Properties of a transaction.
1. Atomicity:
o Ensures that a transaction is treated as a single, indivisible unit of work.
o Either all operations in the transaction are completed, or none are applied.
o Example: If a bank transfer involves deducting money from one account and
adding it to another, both operations must occur, or neither.
2. Consistency:
o Ensures that a transaction brings the database from one valid state to another,
preserving all predefined rules and constraints.
o Example: After a transaction, the total balance across all accounts remains
consistent.
3. Isolation:
o Ensures that concurrent transactions do not interfere with each other.
o Example: If two users are updating the same account balance simultaneously,
isolation ensures that each transaction is executed as if it were alone.
4. Durability:
o Ensures that once a transaction is committed, its changes are permanent, even
in the event of a system crash.
o Example: After completing a purchase, the transaction details remain in the
database regardless of power failures.
Summary:
● Normalization organizes data to reduce redundancy and improve integrity.
● ACID properties ensure reliable, consistent, and durable database transactions.
Conflict Serializability:
Example:
View Serializability:
Example:
● Transactions T1 and T2 on a data item X:
o T1: Read(X), Write(X)
o T2: Read(X), Write(X)
● A schedule where T1 reads and writes before T2 reads and writes is view-serializable,
even if it’s not conflict-serializable
(OR)
b) List down the functions performed by a Database Administrator.
The Database Administrator (DBA) is responsible for managing, maintaining, and ensuring
the efficient operation of the database system. Key functions include:
i) Draw an E-R diagram for a banking enterprise with almost all components and
explain.
An E-R diagram for a banking enterprise typically includes the following components:
1. Entities:
o Customer: Represents the bank's customers with attributes like Customer_ID,
Name, Address, Phone.
o Account: Represents customer accounts with attributes like Account_ID,
Account_Type, Balance.
o Branch: Represents branches of the bank with attributes like Branch_ID,
Branch_Name, Location.
o Loan: Represents loans issued by the bank with attributes like Loan_ID,
Loan_Type, Amount.
2. Relationships:
o Owns: Connects Customer and Account, representing customers owning
accounts.
o Operates: Connects Branch and Account, representing branches managing
accounts.
o Takes: Connects Customer and Loan, representing customers taking loans.
o Issues: Connects Branch and Loan, representing branches issuing loans.
Diagram:
Example Explanation:
ii) What is concurrency control? Explain the two-phase locking protocol with an example.
Concurrency Control: Concurrency control ensures that multiple transactions can execute
simultaneously in a database without violating consistency and integrity. It prevents problems
like:
1. Growing Phase:
o A transaction acquires all the locks it needs but does not release any locks.
o Locks can be shared (read) or exclusive (write).
2. Shrinking Phase:
o Once a transaction releases a lock, it cannot acquire any more locks.
Rules:
Example:
● Transactions:
o T1: Reads and updates Account A.
o T2: Reads and updates Account B.
1. T1's Operations:
o Growing Phase: Acquires a write lock on Account A.
o Shrinking Phase: Releases the lock on Account A.
2. T2's Operations:
o Growing Phase: Acquires a write lock on Account B.
o Shrinking Phase: Releases the lock on Account B.
Benefits:
● Prevents conflicts and ensures that the database remains consistent.
● Guarantees that the schedule is conflict-serializable.
Limitations:
● Deadlocks can still occur if two transactions wait for each other’s locks. This can be
resolved using timeout or deadlock detection mechanisms.