Dbm s Answer
Dbm s Answer
Ans:-
DBMS applications range from banking to education, ensuring the effective management of
large amounts of data. Understanding the various applications of DBMS is crucial for
database professionals and students alike.
1. Railway Reservation System
In the rail route reservation framework, the information base is needed to store the record or
information of ticket appointments, status of train’s appearance, and flight. Additionally, if
trains get late, individuals become acquainted with it through the information base update.
2. Library Management System
There are many books in the library so; it is difficult to store the record of the relative
multitude of books in a register or duplicate. Along these lines, the data set administration
framework (DBMS) is utilized to keep up all the data identified with the name of the book,
issue date, accessibility of the book, and its writer.
3. Banking
Database the executive’s framework is utilized to store the exchange data of the client in the
information base.
4. Education Sector
Presently, assessments are led online by numerous schools and colleges. They deal with all
assessment information through the data set administration framework (DBMS). In spite of
that understudy’s enlistments subtleties, grades, courses, expense, participation, results, and so
forth all the data is put away in the information base.
5. Credit card exchanges
The database Management framework is utilized for buying on charge cards and age of month
to month proclamations.
Q2,19,35] Explain how DDL, DML, DCL used in management of DBMS.
Ans:-
Example of DDL
CREATE TABLE employees (
employee_id INT PRIMARY KEY,
first_name VARCHAR(50), last_name
VARCHAR(50),
hire_date DATE
);
Example of DML
INSERT INTO employees (first_name, last_name, department) VALUES
('Jane', 'Smith', 'HR');
3. Data Control Language (DCL) in SQL
DCL (Data Control Language) includes commands such
as GRANT and REVOKE which mainly deal with the rights, permissions, and other controls
of the database system. These commands are used to control access to data in the database by
granting or revoking permissions.
Common DCL Commands
Command Description Syntax
Example of DCL
GRANT SELECT, UPDATE ON employees TO user_name;
Q3] What is relational database? Describe its basic structure including rows,
tables and columns with suitable example.
Ans:-
The relational model represents how data is stored in Relational Databases. A relational
database consists of a collection of tables each of which is assigned a unique name.
Consider a relation STUDENT with attributes ROLL_NO, NAME, ADDRESS, PHONE,
and AGE shown in the table.
Basic Structure of a Relational Database
A relational database consists of the following components:
1. Table (Relation)
• A table is a collection of related data organized in rows and columns.
• Each table represents an entity (e.g., Students, Employees, Products).
2. Rows (Records or Tuples)
• Each row represents a unique record in the table.
• It contains actual data values for the entity.
3. Columns (Fields or Attributes)
• Columns define the properties of the entity.
• Each column has a unique name and a specific data type (e.g., INTEGER, VARCHAR).
Explanation:
• Table Name: Student
• Columns: Student_ID, Name, Age, Course, Email
• Rows: Each row represents an individual student’s details.
B.Tech
꼡 In this table, Student_ID is the Primary Key, as it uniquely identifies each student.
1. Student Table
Student_ID (PK) Name Age Course_ID (FK)
2. Course Table
꼡 Here, both Emp_ID and Emp_Code are Candidate Keys because they uniquely identify
each row. However, only one (e.g., Emp_ID) is chosen as the Primary Key.
Number in
Can be multiple
Only one per table. Can be multiple in a table.
in a table.
Table
Establishes a
Identifies records in A potential
Usage relationship between candidate for the
its own table. tables. Primary Key.
Q5] Explain ER model and its key components.
Ans:-
꼡 Types of Entities:
• Strong Entity: Has a Primary Key and exists independently (e.g., Student, Employee).
• Weak Entity: Depends on a Strong Entity and does not have a Primary Key (e.g.,
Dependent of Employee).
脥 Example:
In a university database, Student and Course are entities.
2. Attributes
Attributes define the properties of an entity.
꼡 Types of Attributes:
脥 Example:
For a Student entity:
• Attributes: Student_ID (Key), Name, Age, Email, Phone_Number.
3. Relationship
A relationship defines how two or more entities are related to each other.
꼡 Types of Relationships:
• One-to-One (1:1): One entity is related to only one entity (e.g., One person → One
passport).
• One-to-Many (1:M): One entity is related to many entities (e.g., One teacher → Many
students).
• Many-to-Many (M:N): Many entities are related to many entities (e.g., Many students
→ Many courses).
脥 Example:
A Student enrolls in a Course → One-to-Many Relationship (1:M)
脥 Example:
5. Cardinality
Cardinality defines the number of instances of one entity that can be associated with instances
of another entity.
꼡 Types of Cardinality:
脥 Example:
A Library has many Books, but each Book belongs to one Library → One-to-Many (1:M)
Q6] Explain 5 features of DBMS.
Ans:-
A Database Management System (DBMS) is software that enables users to create, store,
retrieve, and manage data efficiently. It provides a structured way to handle large amounts of
data while ensuring security, consistency, and integrity.
脥 Example:
If a student enrolls in a course, DBMS ensures that the Student_ID exists in the Student table
before adding it to the Enrollment table (Foreign Key Constraint).
脥 Example:
• A bank database ensures that only tellers can view customer details, while managers
can approve transactions.
脥 Example:
• Instead of storing department details with every employee record, a separate
Department table is created, linked to the Employee table using Foreign Keys.
脥 Example:
• In an online shopping website, multiple users can place orders at the same time without
affecting each other’s transactions.
脥 Example:
• If a power failure occurs while updating customer information, DBMS rolls back
incomplete transactions to maintain data consistency.
Student Courses
A Math, Physics
Student Course
A Math
A Physics
🔹 Rule: Must be in First Form, and no partial dependency (i.e., no non-key column should
depend only on a part of the primary key).
🔹 Problem: A table with composite primary keys where some columns depend on only part
of the key.
🔹 Solution: Move partially dependent attributes to a separate table.
A Math Prof. X 20
A Physics Prof. Y 20
Student Age
A 20
Course Table
A Math Prof. X
A Physics Prof. Y
🔹 Rule: Must be in Second Form, and no transitive dependencies (i.e., non-key attributes
should not depend on other non-key attributes).
🔹 Problem: A column depends on another non-key column instead of the primary key.
🔹 Solution: Move dependent attributes to a separate table.
A CS Prof. X
B IT Prof. Y
Student Department
A CS
B IT
Department Table
Department HOD
CS Prof. X
IT Prof. Y
4NF (Fourth Normal Form)
A Math Chess
A Math Music
A Physics Chess
A Physics Music
Issue: Hobby is independent of Course, but both depend on Student, causing duplication.
After 4NF (Removing MVDs - Splitting Tables)
✅ Student-Course Table
Student Course
A Math
A Physics
✅ Student-Hobby Table
Student Hobby
A Chess
A Music
42 abc CO A4
43 pqr IT A3
43 pqr 18
44 xyz 18
Here, {roll_no, name} → name is a trivial functional dependency, since the dependent name is
a subset of determinant set {roll_no, name}. Similarly, roll_no → roll_no is also an example
of trivial functional dependency.
2. Non-trivial Functional Dependency
In Non-trivial functional dependency, the dependent is strictly not a subset of the determinant.
i.e. If X → Y and Y is not a subset of X, then it is called Non-trivial functional dependency.
Example 1 :
• Id -> Name
• Name -> DOB Example 2:
42 abc 17
43 pqr 18
44 xyz 18
Here, roll_no → name is a non-trivial functional dependency, since the dependent name is not
a subset of determinant roll_no. Similarly, {roll_no, name} → age is also a non-trivial
functional dependency, since age is not a subset of {roll_no, name}
3. Multivalued Functional Dependency
In Multivalued functional dependency, entities of the dependent set are not dependent on each
other. i.e. If a → {b, c} and there exists no functional dependency between b and c, then it is
called a multivalued functional dependency.
Example:
42 abc CO 4
43 pqr EC 2
44 xyz IT 1
45 abc EC 2
Here, enrol_no → dept and dept → building_no. Hence, according to the axiom of transitivity,
enrol_no → building_no is a valid functional dependency. This is an indirect functional
dependency, hence called Transitive functional dependency.
A user can make different types of requests to access and modify the contents of a database.
So, we have different types of operations relating to a transaction. They are discussed as
follows:
1. Read(X)
A read operation retrieves the value of X from the database and stores it in the main memory
for processing. It is used when a user wants to view data without making changes.
Example: Checking an account balance.
2. Write(X)
A write operation updates the database with a new value from the main memory. Before
writing, a read operation is performed, modifications are made, and then the updated value is
stored.
Example: Withdrawing money from an account.
3. Commit
A commit operation permanently saves the changes made by a transaction. It ensures
data consistency and prevents loss due to failures. Example: Finalizing a bank transfer.
4. Rollback
A rollback operation restores the database to its last stable state if a transaction fails due to
power, hardware, or software issues. It prevents inconsistency. Example: Cancelling a failed
transaction.
Q10,29] Explain ACID properties.
Ans:-
Database engines are MySQL components that can handle SQL operations like create, read,
update data from a database. There are two types of engines in MySQL: transactional and non-
transactional. InnoDB is the default engine for MySQL 5.5 and above versions. Major DBMS
uses an application programming interface(API) to enable the interaction of users with
database engines. It is very necessary to know about the engines for production databases and
it also impacts future development. To access the list of available MySQL engines we
run SHOW ENGINES; query.
There are 2 types of database engines :
• Transactional Databases: In this type, we can roll back the write operations on the
database if they are left incomplete. These operations are known as transactions.
Majorly, modern engines are transactional.
• Non-Transactional Databases: Unlike transactional databases, they don’t provide
Rollback/Commit. Instead, we need to manually code to perform the rollback
operations.
sql
GRANT SELECT ON Patients TO User1;
5. Transaction Control Language (TCL) o Manages
transactions in a database.
o Example:
sql
COMMIT;
ROLLBACK;
Conclusion
Indexing is a crucial technique in DBMS that enhances query performance and data retrieval
efficiency. However, careful index selection and management are necessary to balance performance
and storage overhead.
Types of views:
1 Internal View
• This view deals with physical storage, such as the location of the server and network
information for the server.
2 Conceptual View
• This view describes the logical structure and relationships of the data.
3 External View
• This view provides customized data access for individual users or groups.
4 Physical View
• This view displays the available physical resources and their location within the enterprise.
5 Logical View
• This view defines an information concept in the company data system.
✅ Output:
101 John 1
102 Emma 2
Departments Table:
Dept_ID Department
1 CS
2 IT
Q28] Define the term concurrency control in the context of databases. What
are the different types of concurrency control methods?
Ans:-
Definition of Concurrency Control in Databases
Concurrency control in databases ensures that multiple transactions can execute simultaneously
without leading to inconsistencies, conflicts, or data loss. It maintains the ACID (Atomicity,
Consistency, Isolation, Durability) properties, ensuring that transactions do not interfere with each
other in multi-user environments.
For example, without concurrency control, two users modifying the same bank account balance
simultaneously could lead to incorrect updates.
Q30] Design a database for an online bookstore Include tables for customers,
books, orders, and payment. Provide an ER diagram and mention
relationships.
Ans:-
1. Customers Table
2. Books Table
3. Orders Table
5001 1 2025-03-10
5002 2 2025-03-11
4. OrderDetails Table
5001 101 2
5002 102 1
5. Payments Table
Relationships:
1. Customers → Orders (One-to-Many)
2. Orders → OrderDetails (One-to-Many)
3. Books → OrderDetails (One-to-Many)
4. Orders → Payments (One-to-One)
Advantages:
1. Reduces Redundancy – Prevents duplicate data.
2. Improves Data Integrity – Maintains consistency.
3. Enhances Query Performance – Well-structured tables improve speed.
4. Prevents Anomalies – Avoids insertion, deletion, and update errors.
Disadvantages:
1. Complex Design – Too many tables make it complicated.
2. Slower Joins – More tables lead to slow queries.
3. Difficult Maintenance – Managing dependencies can be hard.
UPDATE Students
SET Age = 21, Grade = 'A+'
WHERE ID = 1;
2. SELECT Command
The SELECT command is used to retrieve data from a table. It allows filtering, sorting, and
aggregation of records.
Example:
Retrieving all students who have grade 'A':
sql
CopyEdit
SELECT Name, Age FROM Students WHERE Grade = 'A';
3. DELETE Command
The DELETE command removes specific records from a table based on a condition.
Example:
Deleting a student with ID = 2:
sql
CopyEdit
DELETE FROM Students WHERE ID = 2;