0% found this document useful (0 votes)
24 views7 pages

Database Design and Query Optimization Guide

The document outlines various database concepts, including table creation with constraints, normalization, transaction management, and SQL queries. It covers topics such as functional dependencies, concurrency control, and database architecture for different systems. Additionally, it discusses the application of PL/SQL, relational algebra, and the importance of data integrity and consistency in database management.
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)
24 views7 pages

Database Design and Query Optimization Guide

The document outlines various database concepts, including table creation with constraints, normalization, transaction management, and SQL queries. It covers topics such as functional dependencies, concurrency control, and database architecture for different systems. Additionally, it discusses the application of PL/SQL, relational algebra, and the importance of data integrity and consistency in database management.
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

1.

Consider a table named "employees" with the following columns:

employee_id (integer), employee_name (text), salary (numeric),hire_date (date).

(a) Define the "employee_id" as the primary key for the "employees" table.

(b) Ensure that each employee's name is unique. Apply a constraint to enforce this
uniqueness.

(c) Allow salaries only in the range of Rs.30,000 to Rs.100,000. Apply a check constraint on
the "salary" column.

(d) Set a default value for the "hire_date" column to be the current date when a new
employee record is inserted.

(e) Create a foreign key relationship between the "employees" table and another table
named "departments."

Ensure that the "department_id" in "employees" references the "department_id" in


"departments."

2. Given the relation schema R(A,B,C,D,E,F) and the set of Functional Dependencies
F={AB->C, BC->D, DE->A, EF->B}.

prove that R is not in BCNF. If R is not in BCNF, decompose it into appropriate relation
schemas that satisfy BCNF

2. Problems on conflict serializable


3. Problems on view serializable
4. Airline Reservation system – ER Diagram

[Link] the given Relation :

Attribute Data Type Constraint


emp_id NUMBER Primary Key
emp_nameVARCHAR2(20)NOT NULL
salary NUMBER —

1. Create the table and insert the data.


2. write a PL/SQL procedure to calculate the annual bonus of an employee based on
salary.
The procedure should accept Employee ID as input and return the bonus amount as
output.

4. Consider the following tables. Compute MYSQL for the following queries:
I. Calculate the total number of boat reservations made on each day, ordered by the
reservation count in descending order.

II. List the names of sailors and the colours of the boats they have reserved, sorted by sailor
name and boat colour.

III. Calculate the average rating of sailors who have reserved a boat on the same day as
they joined the database.

IV. List the names of sailors who have reserved boats with a rating higher than the average
rating of all sailors.

V. Determine the boat name and colour that has been reserved the greatest number of
times.

5. Express the following in terms of Relational Algebra expression by using following


schema S ( SNO, SNAME,CITY,STATUS) P (PNO,PNAME,COLOR,CITY)
SP(SNO,PNO,QTY)

i) Find out the Supplier Name, who supply the part from his location.

ii) Find out the Supplier, who supply the part ‘P2’

iii) Find out the Supplier Names located from the same city.

[Link] the employee database , where the primary keys are Underlined.

employee(empname,street,city) works(empname,companyname,salary)
company(companyname,city) manages(empname,management)

Give an expression in the relational algebra for each request.

I. Find the names of all employees who work for First Bank Corporation.

II. Find the names, street addresses and cities of residence of all employees who work for
First Bank Corporation and earn more than 200000 per annum.

III. Find the names of all employees in this database who live in the same city as the
company for which they work.
[Link] the relation R(ABCDE) and dependencies are defined as follows A -> B, BC -> E,
and ED -> A.

Solve the following situations. 1. List all candidate keys for R. 2. Is R in 3NF?

[Link] your understanding of PL/SQL block structure to write the basic skeleton of an

anonymous PL/SQL block and label its sections.

[Link] transactions, T1 and T2, run concurrently. •T1 reads value X, updates it, and writes it
back.

•T2 reads X before T1 commits, then updates and writes X. •T1 then commits.

Describe the lost update problem in this scenario. How does concurrency control prevent
this issue.

[Link] T1 starts at time 10 and T2 starts at time 20. Both want to update the same
record X.

•T1 reads X. •T2 writes X. •T1 tries to write X.

Apply the timestamp-based protocol rules to this scenario. Which transaction will be rolled
back, and why?.

TimeOperation
1 T1: R(X)
2 T2: R(X)
3 T1: W(X)
4 T2: R(Y)
5 T2: W(X)
6 T1: W(Y)

[Link] the above schedule for two transactions T1 and T2 on data items X and Y:

Determine whether the schedule is view serializable. Show the step-by-step


analysis using read-from, final-write, and view equivalence rules.
11. A company uses a large, denormalized table for its sales records, which has redundancy
issues and

update anomalies. Discover the steps you would take to decompose this table into smaller
relations,

ensuring the decomposition is both lossless and dependency-preserving.

12. Examine the underlying principles and objectives of lock-based protocols in

transaction management, identifying how they function to ensure data consistency and
isolation

13. A library database has a table Library Branch_Book_Author(Branch_ID, Book ID, Author)

with multivalued dependencies {Book_ID →→ Author} and {Branch_ID →→ Book_ID}.

Analyze this scenario, decompose the table to achieve 4NF, and discuss the effect on

data redundancy and maintenance

14. Analyze the process in a database system that uses shadow paging for recovery when a
transaction is interrupted during an update. How does shadow paging address incomplete
transactions to maintain data integrity?

15. Examine how ARIES handles a scenario with multiple transaction failures, including
those with

dependent actions. Analyze the methods ARIES uses to ensure consistency and atomicity
during

recovery.

[Link] a relation R(StudentID, CourseID, Instructor, InstructorRoom) with the following


functional dependencies:

 StudentID, CourseID → Instructor


 Instructor → InstructorRoom

(a) Analyze whether the given relation R is in 3NF OR BCNF


(b) If it is not in BCNF, apply BCNF decomposition to convert the relation into BCNF
and list the resulting relations with their functional dependencies.

17. Given a table EMPLOYEE(EmpID, EmpName, Department, Salary), write SQL queries
using aggregate functions to:

(i) Calculate the average salary of employees in each department.


(ii) Find the total number of employees working in the “HR” department.

18.
Apply the concept of referential integrity by creating a relational schema for a library
management system, ensuring that foreign key constraints are properly implemented
Given a table STUDENT(StudentID, StudentName, Branch, Marks), write SQL queries using
aggregate functions to:

(i) Calculate the average marks of students in each branch.


(ii) Find the total number of students in the “CSE” branch.

(Imp)19. Construct a database architecture for a retail chain that ensures data consistency
across multiple stores while allowing for localized data access.

(imp) 20. Apply SQL to design complex queries that retrieve specific data from a large, multi-
table database for a business intelligence report.

21. Utilize the benefits of Strict 2PL in terms of database concurrency and consistency

22. Consider the attribute set R = ABCDEGH and the FD set

F={AB->C, AC->B, AD->E, B->D,BC->A,E->G}.

Solve the minimal cover for the given set of Functional Dependencies.

23. Construct an ER diagram for a Hospital management system, clearly identifying all
entities, attributes, and relationships.

(imp) 24. In an online banking system, multiple users perform transactions such as fund
transfers, deposits, and withdrawals simultaneously. Apply the ACID properties to explain
how the database ensures that a fund transfer transaction is executed correctly even in the
presence of system failures or concurrent access.

(imp) 25. A company plans to change the physical storage of its database by moving data
from a traditional hard disk system to a cloud-based storage solution to improve
performance and scalability. Apply the concept of data independence to explain how this
change can be implemented without affecting the logical structure of the database or the
application programs. Clearly state the type of data independence involved.

(imp)26. Model the steps you would take to convert the table to 2NF by removing partial
dependencies

with an example.

(imp)27. Choose appropriate constraints (e.g., primary key, foreign key, unique) for a
relational schema of a

retail store’s inventory system and justify your choices.

(imp)28. Apply SQL commands to create, modify, and query a database, demonstrating
practical usage
(imp)29. Apply the concept of data independence to a scenario where the physical storage
of data needs to be changed without affecting the logical structure of the database.

(imp)30. Develop a database architecture for a retail chain that ensures consistent data
across all stores while enabling efficient local access to store-specific information.

(imp) 31. Build an ER diagram for a Airline management system, ensuring that all relevant
constraints and relationships are accurately represented.

(imp) 32. Build a small database for an e-commerce platform, emphasizing how DBMS
characteristics like

security and data integrity benefit the business.

(imp) 33. Model a scenario where changes to the database schema can be made
independently of the

data storage structure, ensuring flexibility in database management.

(imp) 34. Apply the concept of referential integrity by creating a relational schema for a

library management system, ensuring that foreign key constraints are properly implemented.

(imp) 35. Apply appropriate SQL integrity constraints (such as PRIMARY KEY, FOREIGN
KEY, UNIQUE, NOT NULL, and CHECK) to a relational database table and explain how
these constraints help in preventing data anomalies and maintaining data integrity.

36. Consider a relation R with attributes A,B,C,D,E. You are given the following FD's

F={ A->B BC->E ED->A } List all the candidate keys for R and find the highest normal form

37. Given the following table with functional dependencies, simplify the table by normalizing
it to

3NF: R (SID, PID, SNAME, SCITY, STATUS, PNAME, QTY)

Functional dependencies: SID → SNAME, SCITY

SCITY → STATUS

PID → PNAME

SID, PID → QTY

38. Examine the set of functional dependencies F={A→B,B→C,A→D} for the relational
schema

R={A,B,C,D} Find the closure of the attributes starting from A, and

explain the steps involved in determining all possible functional dependencies


39. A library database has a table Library_Branch_Book_Author(Branch_ID, Book_ID,
Author) with

multivalued dependencies {Book_ID →→ Author} and {Branch_ID →→ Book_ID}.

Analyze this scenario, decompose the table to achieve 4NF, and discuss the effect on

data redundancy and maintenance.

40. Examine the underlying principles and objectives of lock-based protocols in transaction

management, identifying how they function to ensure data consistency and isolation

41. In a payroll system, two transactions are simultaneously updating the salaries of
employees.

Discover how locking protocols ensure consistency in such a scenario.

What kind of locks (e.g., row-level or table-level) should be used?

42. Given the following transactions and their timestamps—T1 (Timestamp 1) writes on data
item X, T2 (Timestamp 2) writes on X, and T3 (Timestamp 3) reads X—apply the Timestamp
Ordering Protocol to determine the state of each transaction and the resulting outcome.

43. Analyze the process in a database system that uses shadow paging for recovery when a
transaction is

interrupted during an update. How does shadow paging address incomplete transactions to

maintain data integrity?

You might also like