0% found this document useful (0 votes)
10 views19 pages

Database QB1

Uploaded by

Jothi Vimal Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views19 pages

Database QB1

Uploaded by

Jothi Vimal Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

ONLINE_JULY23-V20UDS203 (#110)

Total Marks: 70
Total Duration: 150 minutes

Instructions

PART - A

Answer all 25 MCQs (25 X 1 = 25 Marks)

PART - B

Answer all 5 Descriptive Questions (5 X 5 = 25 Marks)

PART - C

Answer the Descriptive Question (1 X 20 = 20 Marks)

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.

Instructions for DESCRIPTIVE questions requiring SCAN & UPLOAD

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.

Q1: Difficulty Level: Very Easy

DBMS is:

● ○ collection of queries
● ○ high-level language
● ○ programming language
● ● stores, modifies and retrieves data

Q2: Difficulty Level: Very Easy

Which of the following is not a type of database?

● ○ Hierarchical
● ○ Network
● ○ Distributed
● ● Decentralized

Q3: Difficulty Level: Very Easy

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

Q4: Difficulty Level: Very Easy

Data Manipulation Language is used for:

● ● insert the data


● ○ create the table
● ○ modify the attribute size
● ○ drop the field
Q5: Difficulty Level: Very Easy

Which command is used to remove a relation from an SQL?

● ○ Remove
● ● drop table
● ○ del
● ○ erase

Q6: Difficulty Level: Very Easy

__________ operations do not preserve non-matched tuples.

● ○ Left outer join


● ● inner join
● ○ natural join
● ○ right outer join

Q7: Difficulty Level: Very Easy

SELECT emp_name FROM department WHERE dept_name LIKE '_____ Computer


Science';
In the above-given query, which of the following can be placed in the Query's blank portion
to select the "dept_name" that also contains Computer Science as its ending string?

● ○&
● ○.
● ●%
● ○@

Q8: Difficulty Level: Very Easy

Which of the following refers to the number of entities participating in a relation?

● ○ Column
● ○ specialisation
● ○ Generalization
● ● cardinality

Q9: Difficulty Level: Very Easy


In which one of the following, the multiple lower entities are grouped (or combined)
together to form a single higher-level entity?

● ○ Specialization
● ● Generalization
● ○ Aggregation
● ○ Relation

Q10: Difficulty Level: Very Easy

Which of the following keys is generally used to represent the relationships between the
tables?

● ○ unique
● ○ candidate
● ● Foreign
● ○ primary

Q11: Difficulty Level: Very Easy

Which one of the following keywords is used to find out the number of values in a
column?

● ○ sum
● ○ total
● ● count
● ○ add

Q12: Difficulty Level: Very Easy

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

Which of the following is not an Aggregate function?

● ○ sum
● ○ min
● ● select
● ○ max

Q14: Difficulty Level: Very Easy

In SQL, the _______ command is used to recompile a view.

● ○ define view
● ○ recompile view
● ○ update view
● ● alter view

Q15: Difficulty Level: Very Easy

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:

● ○ The pin code


● ○ The last name
● ● A compound key consisting of the first name and the last name
● ○ first name

Q16: Difficulty Level: Very Easy

A compound key consisting of the first name and the last name belongs to which normal
form?

● ● First normal form


● ○ Second normal form
● ○ Third normal form
● ○ BCNF
Q17: Difficulty Level: Very Easy

A table is in BCNF if it is in 3NF and if every determinant is a ________ key.

● ○ dependent
● ● candidate
● ○ prime
● ○ super

Q18: Difficulty Level: Very Easy

A table is in 3NF if it is in 2NF and if it has no ____________.

● ● Transitive dependency
● ○ joint dependency
● ○ function dependency
● ○ multi-dependency

Q19: Difficulty Level: Very Easy

Candidate key is __________ of super key.

● ● minimal
● ○ equal
● ○ like
● ○ maximal

Q20: Difficulty Level: Very Easy

Which of the following is not a Key in SQL Server?

● ○ unique
● ○ primary
● ○ not null
● ● null

Q21: Difficulty Level: Very Easy

Which of the following is an operation of transactions?


● ● write
● ○ create
● ○ delete
● ○ drop

Q22: Difficulty Level: Very Easy

___ operation is used to save the work permanently.

● ○ edit
● ○ write
● ○ save
● ● commit

Q23: Difficulty Level: Very Easy

How many properties of transactions are there?

● ●4
● ○5
● ○3
● ○6

Q24: Difficulty Level: Very Easy

Data integrity is ________.

● ○ providing data sharing


● ○ providing first access to stored data
● ● ensuring correctness and consistency of data
● ○ available to all

Q25: Difficulty Level: Very Easy

Which of the following is not a function of DBA?

● ○ authorization for data access


● ● network maintenance
● ○ schema definition
● ○ create users

Section: PART B

Marks per question: 5


5 of 5 question(s) in this section will be shown to examinee.
Examinee should answer all 5 question(s) in this section.

Q1: Difficulty Level: Easy

a) List the disadvantages of the file system over the database.

a) Disadvantages of File System over Database

1. Data Redundancy and Inconsistency: In a file system, data is often duplicated,


leading to redundancy and inconsistency when multiple copies of the same data exist.
2. Lack of Data Integrity: The file system cannot enforce constraints, leading to
incorrect or inconsistent data entries.
3. Limited Query Capabilities: File systems do not support powerful querying
mechanisms like SQL in databases, making data retrieval complex and slow.
4. Poor Security: File systems lack robust security measures, making it difficult to
control access to sensitive information.
5. Concurrent Access Issues: File systems are not designed for simultaneous access by
multiple users, leading to data corruption.
6. Difficulty in Data Recovery: File systems provide limited tools for recovering data
in case of system failures or crashes.
7. No Support for Transactions: File systems do not offer ACID properties
(Atomicity, Consistency, Isolation, Durability), which databases provide for reliable
transaction management.

(OR)
b) Explain the following with examples:
i) DDL (2.5)
ii) DML (2.5)

i) DDL (Data Definition Language)


DDL is a set of SQL commands used to define or modify the structure of database objects
such as tables, schemas, or indexes. These commands do not manipulate the data itself.

● 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)
);

o ALTER:To modify an existing database object.


Example:

sql
Copy code
ALTER TABLE Employee ADD Department VARCHAR(50);

o DROP:To delete a database object permanently.


Example:

sql
Copy code
DROP TABLE Employee;

ii) DML (Data Manipulation Language)


DML commands are used to manipulate data within database objects. These commands allow
users to retrieve, insert, update, and delete data.

● 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);

o UPDATE:To modify existing records in a table.


Example:

sql
Copy code
UPDATE Employee
SET Salary = 55000
WHERE EmpID = 1;

o DELETE:To remove records from a table.


Example:

sql
Copy code
DELETE FROM Employee
WHERE EmpID = 1;

o SELECT:To retrieve data from a table.


Example:

sql
Copy code
SELECT * FROM Employee WHERE Salary > 40000;

This completes the explanation of DDL and DML with examples.

Q2: Difficulty Level: Medium

a) Write a short note on the E-R Data Model and how it is represented.

a) E-R Data Model and its Representation

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.

1. Components of the E-R Model:


o Entities: Represent real-world objects or concepts, such as Employee,
Department, etc.
o Attributes: Represent properties of entities, such as Name, Salary,
Department_ID.
o Relationships: Represent associations between entities, such as Works_In
(association between Employee and Department).
2. Representation:
o Entities are represented as rectangles.
o Attributes are represented as ovals connected to their respective entities.
o Relationships are represented as diamonds, connecting the related entities.
o Primary Keys are underlined in the attributes of an entity.
o Cardinality indicates the type of relationship (one-to-one, one-to-many, or
many-to-many).
3. Example:
o An E-R diagram for an Employee and Department system might include:
▪ Employee entity with attributes Emp_ID, Name, Salary.

▪ Department entity with attributes Dept_ID, Dept_Name.


▪ Works_In relationship between Employee and Department.

(OR)
b) Write the steps to convert an ER diagram into tables. Explain with an example.

b) Steps to Convert an ER Diagram into Tables

Converting an ER diagram into tables involves systematically mapping entities, attributes,


and relationships to a relational schema.

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)

▪ Works_In relationship is handled by the foreign key Dept_ID in


Employee.

Q3: Difficulty Level: Medium

a) List out the operations of relational algebra with a suitable example (Any five).

a) Operations of Relational Algebra with Examples

Relational Algebra is a procedural query language that operates on relations (tables) to


produce required results. Below are five key operations:
1. Selection (σ): Used to select rows from a relation that satisfy a given predicate.
Example:
scss
Copy code
σ(Salary > 50000) (Employee)
Retrieves employees with a salary greater than 50,000.
2. Projection (π): Used to select specific columns from a relation.
Example:
scss
Copy code
π(Name, Salary) (Employee)
Retrieves only the Name and Salary
columns of the Employee relation.
3. Union (∪): Combines tuples from two relations, eliminating duplicates.
Example:
Copy code
Employee ∪ Manager
Retrieves all distinct tuples from the Employee and Manager relations.
4. Set Difference (-): Finds tuples present in one relation but not in the other.
Example:
Copy code
Employee - RetiredEmployee
Retrieves all employees who are not retired.
5. Join (⋈): Combines tuples from two relations based on a common attribute.
Example:
Copy code
Employee ⋈ Dept_ID=Dept_ID Department
Retrieves a relation combining Employee and Department where Dept_ID matches.

(OR)
b) Consider the relational table given below and assess the following SQL queries.

Employee (Empno, Name, Dept, Salary):


i) List all the employees whose names start with the letter 'L.'
ii) Find the maximum salary given to employees in each department.
iii) Find the number of employees working in the 'accounts' department.

SQL Queries Based on the Relational Table

Given the Employee table:


Employee (Empno, Name, Dept, Salary)

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.'

ii) Find the maximum salary given to employees in each department:

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.

iii) Find the number of employees working in the 'accounts' department:

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.'

Q4: Difficulty Level: Medium

a) What is Normalization? Explain the need for normalization.

Normalization is the process of organizing data in a database to reduce redundancy and


improve data integrity. It involves decomposing a database into multiple related tables to
minimize duplication and ensure logical data storage.

Key Goals of Normalization:

1. Eliminate redundant data.


2. Ensure data dependencies are logical and stored systematically.
3. Improve data integrity and consistency.

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.

Need for Normalization:

1. Reduce Data Redundancy: Minimizes unnecessary duplication of data to save


storage and prevent inconsistencies.
2. Avoid Update Anomalies: Prevents issues like needing to update the same data in
multiple places.
3. Improve Data Integrity: Ensures consistency and accuracy of data across the
database.
4. Simplify Queries: Organizes data in a logical manner, making queries more efficient.
5. Facilitate Scalability: Well-normalized databases are easier to maintain and expand.

Example: Unnormalized Table:

Student_I Na Course Course


D me _1 _2
Alic
101 Math Science
e

After Normalization (1NF):

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.

Describe the ACID Properties of a Transaction

ACID properties ensure reliable processing of database transactions, maintaining data


integrity even in the event of system failures.

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.

Q5: Difficulty Level: Medium

a) Discuss conflict serializability and view serializability.

Conflict Serializability:

● Conflict serializability ensures that the schedule of transactions is conflict-equivalent


to a serial schedule.
● A schedule is conflict-equivalent if the order of conflicting operations (read/write,
write/write on the same data item) in the schedule is the same as in some serial
schedule.
● To check conflict serializability, a precedence graph is used:
1. Create a directed graph where each node represents a transaction.
2. Add an edge between transactions if one transaction's operation conflicts with
another and happens earlier.
3. If the graph has no cycles, the schedule is conflict-serializable.

Example:

● Transactions T1 and T2 on a data item X:


o T1: Read(X), Write(X)
o T2: Write(X)
● If T1 and T2 are executed such that T1 finishes its operations before T2 begins, the
schedule is conflict-serializable.

View Serializability:

● A schedule is view serializable if it is view-equivalent to a serial schedule.


● View equivalence is determined based on:
1. Initial Reads: Each transaction in both schedules reads the same initial values.
2. Final Writes: The final write operations in both schedules are the same.
3. Intermediate Reads: The data read by one transaction in both schedules is
written by the same transaction.
● View serializability is less strict than conflict serializability since all conflict-
serializable schedules are view-serializable, but the reverse is not true.

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:

1. Database Design and Implementation:


o Designing the database structure, including tables, indexes, and schemas.
o Ensuring that the database design aligns with organizational needs.
2. Security Management:
o Controlling access to the database by creating user accounts and assigning
roles.
o Implementing authentication and authorization mechanisms.
3. Backup and Recovery:
o Planning and executing regular backups of the database.
o Restoring data during system failures or disasters.
4. Performance Optimization:
o Monitoring database performance and tuning queries, indexes, and
configurations.
o Managing resources to ensure optimal performance.
5. Data Integrity and Consistency:
o Ensuring that data remains accurate, consistent, and compliant with business
rules.
o Enforcing constraints, such as primary and foreign keys.
6. Database Maintenance:
o Performing regular maintenance tasks like defragmenting storage, updating
indexes, and optimizing tables.
7. Software Updates and Patching:
o Keeping the database management system (DBMS) software up-to-date with
patches and upgrades.
8. Capacity Planning:
o Estimating future storage and processing needs.
o Scaling the database infrastructure to meet organizational growth.
9. Troubleshooting and Support:
o Diagnosing and resolving database-related issues.
o Supporting developers and users by providing technical assistance.
10. Transaction Management:
o Managing and monitoring transactions to ensure ACID properties are
maintained.
Section: PART C

Marks per question: 20


1 of 1 question(s) in this section will be shown to examinee.
Examinee should answer all 1 question(s) in this section.

Q1: Difficulty Level: Medium

i) Draw an E-R diagram for a banking enterprise with almost all components and
explain.

E-R Diagram for a Banking Enterprise

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:

● Entities (Customer, Account, Branch, Loan) are represented by rectangles.


● Relationships (Owns, Operates, Takes, Issues) are represented by diamonds.
● Attributes (e.g., Customer_ID, Account_ID) are represented by ovals.

Example Explanation:

● A customer can own multiple accounts and take multiple loans.


● Each account and loan are associated with a branch.
● This structure provides a clear relationship between all banking components.
(Note: The E-R diagram cannot be directly drawn in text form. A visualization tool or
drawing is recommended to represent this accurately.)

ii) What is concurrency control? Explain the two-phase locking protocol with an example.

Concurrency Control and Two-Phase Locking Protocol

Concurrency Control: Concurrency control ensures that multiple transactions can execute
simultaneously in a database without violating consistency and integrity. It prevents problems
like:

● Dirty Reads: Reading uncommitted changes made by another transaction.


● Lost Updates: Overwriting updates made by concurrent transactions.
● Inconsistent Reads: Transactions seeing inconsistent states of the database.

Two-Phase Locking Protocol (2PL): The Two-Phase Locking Protocol is a concurrency


control mechanism that ensures serializability by dividing the execution of a transaction into
two phases:

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:

● No locks are acquired after the first unlock.


● Ensures there are no cyclic dependencies, avoiding deadlocks.

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.

You might also like