Professional Documents
Culture Documents
DBMS
DBMS
Group No :18
Guided BY :-Prof.B.B.Pawar
Group Members
Name Roll No
Sanjana Lahamage 76
Vinod Nangare 86
Harshal Patil 96
Rutuja Rajput 106
Parvej Shaikh 116
Bharti Sonawane 126
Vaishnavi Zarekar 136
ER-Model
1. Draw ER model with any suitable database and implement in MySQL DDL & DML
commands.
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information
ER-Model
DDL Queries :
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information
ER-Model
3.Creating Table For Voters :
CREATE TABLE Voters (
VoterID INT PRIMARY KEY,
Name VARCHAR(100),
Age INT,
Address VARCHAR(255)
);
DML Queries :
1. Inserting data into the Candidates table:
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information
ER-Model
2.Inserting data into the Votes table (assuming a vote is cast by a voter for
a candidate):
INSERT INTO Votes (VID, Voter_ID, C_ID)
VALUES (1, 1, 1);
These commands provide a basic structure for managing candidates, votes, and voters in an online voting system.
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information
Nested Subquery
2. Demonstrate the nested subquery with any suitable database in
MySQL.
Employee id name Department id
department_id name
1 Alice 1
1 Engineering
2 Bob 2
3 Charlie 1 2 Marketing
4 David 3 3 HR
5 Eve 1
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology
Nested Subquery
SELECT name
FROM employees
WHERE department_id = (
SELECT department_id
FROM departments
);
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology
Output
If we run the provided query, the output would be:
Digital Electronics & Computer Organization– CIA PART B Presentation I Guided by Mr. A. A. Barbind Department of Information
Triggers
3. Implement and demonstrate use of triggers with any suitable database in
MySQL
Use of Trigger :
"Triggers are essential components in programming that automatically initiate actions based on certain
conditions or events. They serve as powerful tools to execute specific tasks, such as updating a database,
sending notifications, or performing calculations, when predefined conditions are met. Integrating triggers
into your application architecture enhances efficiency, automation, and responsiveness, thereby streamlining
processes and improving user experiences."
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology
Triggers
First, let's create the tables:
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology
Triggers
Now, let's create a trigger that logs every time a new order is inserted into the orders table:
DELIMITER //
CREATE TRIGGER after_order_insert
AFTER INSERT ON orders
FOR EACH ROW
BEGIN
INSERT INTO order_logs (action, order_id)
VALUES ('Inserted', NEW.order_id);
END;
//
DELIMITER ;
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology
Triggers
Now, let's insert a new order into the orders table and observe how the trigger logs the action in the order_logs table:
After executing this insert statement, if we query the order_logs table, we should see a new entry indicating that an
order was inserted:
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology
Join Dependencies and the Normal Form
4. Join Dependencies and the Fifth Normal Form
Join dependencies are a concept in database normalization theory, particularly relevant to higher normal forms
beyond 3NF (Third Normal Form). The Fifth Normal Form (5NF) deals with eliminating join dependencies.
1.Join Dependency:
• A join dependency exists when a table can be reconstructed by joining two or more other tables. In simpler
terms, it's a constraint on a relation (table) where its tuples can be recreated by joining other tables together.
• For example, let's say we have three tables: A, B, and C. If we can reconstruct table A by joining B and C
together (without any additional attributes), then there exists a join dependency.
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology
Join Dependencies and the Normal Form
Example:
Let's consider a database schema with three tables:
• Students (student_id, student_name)
• Courses (course_id, course_name)
• Enrollments (student_id, course_id, semester)
• Here, Enrollments table represents a many-to-many relationship between Students and Courses.
• If we can reconstruct the Enrollments table by joining Students and Courses (using student_id and course_id),
then there exists a join dependency.
• To achieve 5NF, we might decompose Enrollments into two separate tables: Student_Courses (student_id,
course_id) and Semester_Details (student_id, course_id, semester), where Student_Courses represents the
relationship between students and courses, and Semester_Details provides additional details such as semester
information.
In summary, join dependencies are constraints that indicate a relation can be reconstructed by joining other relations
together. Fifth Normal Form (5NF) aims to eliminate these dependencies to ensure a more robust and efficient database
schema, free from certain types of anomalies.
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology
Log-Based Recovery
5.Log-Based Recovery
Log-based recovery is a technique used in database management systems (DBMS) to ensure data consistency and recover from
failures. It involves the use of transaction logs, which record all changes made to the database, to restore the database to a
consistent state in the event of a failure or system crash.
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology
Log-Based Recovery
5. Redo and Undo Operations: The recovery process typically involves two types of operations:
• Redo: Reapplying committed transactions from the log to ensure that all changes are correctly
reapplied to the database.
• Undo: Rolling back uncommitted or partially committed transactions by undoing their effects on
the database.
6. Checkpointing: Periodically, the DBMS creates checkpoints to reduce the amount of work
required during recovery. A checkpoint is a point in time where all modifications up to that point
have been written to disk. It involves flushing all modified data from memory to disk and
updating the checkpoint record in the log.
Overall, log-based recovery ensures data consistency and durability by recording all changes to the database
in a transaction log and using that log to recover the database to a consistent state in the event of failures or
crashes. It is a fundamental mechanism employed by DBMS to maintain data integrity and reliability.
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology
MongoDB
6. Implement any suitable database application in MongoDB and perform
Indexes.
1. Create a Database and Collection:
use bookstore
db.createCollection("books")
db.books.insertMany([
{ title: "The Great Gatsby", author: "F. Scott Fitzgerald", category: "Fiction" },
{ title: "To Kill a Mockingbird", author: "Harper Lee", category: "Fiction" },
{ title: "The Catcher in the Rye", author: "J.D. Salinger", category: "Fiction" },
{ title: "1984", author: "George Orwell", category: "Science Fiction" },
{ title: "Pride and Prejudice", author: "Jane Austen", category: "Classic" }
])
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology
MongoDB
3.Create Indexes:
Let's create an index on the title field to improve the performance of queries that filter by the book title.
db.books.createIndex({ title: 1 })
4.Perform Queries:
Now, you can perform queries on the books collection. For example, to find all books in the "Fiction" category:
db.books.find({ category: "Fiction" })
In this example, we created a simple database application in MongoDB to manage a collection of books and
performed indexing on the title field to optimize query performance. Remember to consider your application's
specific requirements when creating indexes to ensure they provide the most benefit.
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology
Conclusion
"In conclusion, we covered essential topics in database management, including ER modeling and
implementation in MySQL, nested subqueries for complex data retrieval, normalization concepts like
Join Dependencies and Fifth Normal Form (5NF), log-based recovery techniques, and MongoDB
application development with indexing for query optimization. Understanding these concepts is crucial
for designing efficient, reliable, and scalable database systems that meet the needs of modern
applications."
Database Management System CIA PART B Presentation I Guided by Prof:B.B.Pawar Department of Information Technology