0% found this document useful (0 votes)
27 views3 pages

Exp 10

The document outlines the end-to-end implementation of a database schema for a system, detailing the steps from system specification to querying. It includes identifying functional and non-functional requirements, designing an initial schema, refining it through normalization, and optimizing it based on query requirements. Illustrations of SQL queries for extracting information from the system are also provided.

Uploaded by

23211a3234
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)
27 views3 pages

Exp 10

The document outlines the end-to-end implementation of a database schema for a system, detailing the steps from system specification to querying. It includes identifying functional and non-functional requirements, designing an initial schema, refining it through normalization, and optimizing it based on query requirements. Illustrations of SQL queries for extracting information from the system are also provided.

Uploaded by

23211a3234
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

10.

End to end implementation of a schema for a specific system along with the illustrations of
querying. A system is described by specifying the functional and non-functional requirements.
Based on this description, the major entities are identified and modeled. Further the relationships
are modelled to form the initial schema. The schema is further refined by removing redundancies
through normalization. Also based on the query requirements, the schema is remodeled to
facilitate querying. Finally an illustration of various queries to extract required information from
the system is shown using SQL / MYSQL. The five major workflows to be implemented are:

1. System Specification
2. Design of Initial Schema
3. Schema refinement using functional dependencies and normalization
4. Schema refinement using query requirements
5. Illustration of querying the system using SQL / MYSQL.

Here's a structured plan for implementing the end-to-end schema along with querying
illustrations:

1. System Specification
 Identify Functional Requirements (FRs):
o What functionalities will the system support?
o Example: A Library Management System (LMS) should allow book borrowing,
returning, cataloging, and user management.
 Identify Non-Functional Requirements (NFRs):
o Performance constraints (e.g., fast retrieval of book availability).
o Security constraints (e.g., role-based access control).

2. Design of Initial Schema


 Identify major Entities and their Attributes:
o Example (for LMS):
 Book (Book_ID, Title, Author, ISBN, Publisher, Year, Category)
 User (User_ID, Name, Email, Role)
 Borrow (Borrow_ID, User_ID, Book_ID, Borrow_Date, Return_Date,
Status)
 Identify Relationships:
o One-to-Many (User → Borrows → Book)
o Many-to-Many (Book ←→ Author)
 Create an ER Model and convert it into relational schema.
3. Schema Refinement Using Functional Dependencies and
Normalization
 Identify Functional Dependencies (FDs):
o Example:
 ISBN → Title, Author, Publisher (A book's ISBN uniquely determines its
details).
 (User_ID, Book_ID) → Borrow_Date, Return_Date (A unique
combination of User_ID and Book_ID determines borrowing details).
 Normalize:
o 1NF: Ensure atomicity (e.g., separating multi-valued attributes like Authors).
o 2NF: Remove partial dependencies (e.g., ensuring Borrow details depend fully on
primary keys).
o 3NF: Remove transitive dependencies (e.g., Publisher details stored separately if
needed).

4. Schema Refinement Using Query Requirements


 Identify frequent queries:
o Example queries:
1. Retrieve available books by category.
2. Get the list of overdue books.
3. Find the most borrowed books.
 Optimize Schema:
o Add indexes on frequently searched fields (e.g., Book_ID, User_ID).
o Use denormalization if required for faster query retrieval.

5. Illustration of Querying the System Using SQL / MySQL


(i) Creating Tables
CREATE TABLE Book (
Book_ID INT PRIMARY KEY,
Title VARCHAR(255),
Author VARCHAR(255),
ISBN VARCHAR(13) UNIQUE,
Publisher VARCHAR(255),
Year INT,
Category VARCHAR(100)
);

CREATE TABLE User (


User_ID INT PRIMARY KEY,
Name VARCHAR(255),
Email VARCHAR(255) UNIQUE,
Role ENUM('Student', 'Faculty', 'Librarian')
);

CREATE TABLE Borrow (


Borrow_ID INT PRIMARY KEY AUTO_INCREMENT,
User_ID INT,
Book_ID INT,
Borrow_Date DATE,
Return_Date DATE,
Status ENUM('Borrowed', 'Returned'),
FOREIGN KEY (User_ID) REFERENCES User(User_ID),
FOREIGN KEY (Book_ID) REFERENCES Book(Book_ID)
);

(ii) Query Examples

1. Retrieve available books in a given category

SELECT * FROM Book WHERE Category = 'Science'


AND Book_ID NOT IN (SELECT Book_ID FROM Borrow WHERE Status = 'Borrowed');

2. Find all overdue books

SELECT [Link], [Link], Br.Borrow_Date, Br.Return_Date


FROM Borrow Br
JOIN User U ON Br.User_ID = U.User_ID
JOIN Book B ON Br.Book_ID = B.Book_ID
WHERE [Link] = 'Borrowed' AND Br.Return_Date < CURDATE();

3. Find the most borrowed books

SELECT [Link], COUNT(Br.Book_ID) AS BorrowCount


FROM Borrow Br
JOIN Book B ON Br.Book_ID = B.Book_ID
GROUP BY [Link]
ORDER BY BorrowCount DESC
LIMIT 5;

You might also like