0% found this document useful (0 votes)
17 views38 pages

DBMS Madam Impt List

The document provides a comprehensive overview of database systems, covering key concepts such as the differences between file systems and database systems, the definitions of schema and instance, and the importance of data independence. It discusses various components of a database system, types of database users, and the significance of the three-tier schema architecture. Additionally, it explores relational models, constraints, null values, and SQL commands, along with long answer explanations on various database concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views38 pages

DBMS Madam Impt List

The document provides a comprehensive overview of database systems, covering key concepts such as the differences between file systems and database systems, the definitions of schema and instance, and the importance of data independence. It discusses various components of a database system, types of database users, and the significance of the three-tier schema architecture. Additionally, it explores relational models, constraints, null values, and SQL commands, along with long answer explanations on various database concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Unit 1:

2marks

1. What is the difference between a database system and a le system?

• A le system stores data in les without any relation or security.

• A database system (DBMS) manages data using tables, supports querying, provides
security, and reduces redundancy.

2. De ne the terms schema and instance in a database.

• Schema is the structure or design of a database (like table de nitions).

• Instance is the actual data stored in the database at a speci c moment.

3. What is data independence? Name its types.

• Data independence refers to the ability to change the schema at one level without affecting
the other levels.

• Types:

1. Logical Data Independence

2. Physical Data Independence

4. List any two advantages of using a database management system.

1. Reduces data redundancy by centralizing data.

2. Provides data security with access control and permissions.

5. What is a relationship set in an ER model?

• A relationship set is a collection of relationships of the same type between entity sets.
Example: Enrolled relates Student and Course.

6. Name and de ne any two types of database users.

1. DBA (Database Administrator) – Manages database access, backup, and recovery.

2. End Users – Use applications to retrieve or update data (like checking results or booking
tickets).
fi
fi
fi
fi
fi
fi
fi
7. What is the purpose of the three-tier schema architecture in DBMS?

• It separates the user view, logical structure, and physical storage, allowing data
independence and easier management.

8. De ne specialization and generalization in the ER model.

• Specialization: Dividing a higher-level entity into sub-entities based on speci c features.

• Generalization: Combining similar lower-level entities into a single higher-level entity.

LONG ANSWERS

1. Compare the Characteristics of the File System and Database System with Proper
Examples (10 Marks)

File System: A le system stores data in les that are scattered across the disk and managed by the
operating system. Each le may represent a different type of data, and relationships are not
enforced.

Database System (DBMS): A DBMS stores data in a structured way using tables with
relationships. It provides tools for data management, querying, and integrity enforcement.

Characteristic File System Database System (DBMS)


Data High, as same data may be stored in Low, due to normalization and shared
Redundancy multiple les access
Data Integrity Dif cult to enforce Enforced using constraints and rules
Data Security Basic OS-level permissions Advanced role-based access control
Backup & Manual and error-prone Automated and reliable
Recovery
Data Access Through custom programs Through SQL and DBMS interfaces
Querying Limited and procedural Powerful and declarative (SQL)
Capability
Concurrency ACID transactions ensure
Not handled
Control consistency
Example Employee.txt, Salary.txt Employee and Salary tables with
relations
Conclusion: DBMS offers superior data management features, reduced redundancy, and better
security compared to the le system.

2. Structure and Components of a Database System in Detail (10 Marks)

A database system is composed of several components that work together to manage data
effectively.

Components:

1. Hardware: Physical devices like servers, storage systems, and client terminals.
fi
fi
fi
fi
fi
fi
fi
fi
2. Software: Includes the DBMS software (e.g., Oracle, MySQL), OS, and application
interfaces.

3. Data: The actual data stored, along with metadata and system logs.

4. Users: People interacting with the system (DBA, developers, end users).

5. Procedures: Rules and instructions on using and managing the DBMS.

DBMS Subcomponents:

• Query Processor: Interprets SQL queries and converts them into low-level instructions.

• Storage Manager: Handles allocation and retrieval of data.

• Transaction Manager: Ensures ACID properties for data consistency.

• Buffer Manager: Manages data in main memory.

• Authorization Manager: Controls access to data based on roles.

Diagram:

[Users] → [DBMS Interfaces] → [Query Processor] → [Storage/


Buffer/Transaction Manager] → [Disk Storage]

3. Different Types of Users in a Database Environment and Their Roles (10 Marks)

1. Database Administrator (DBA):


◦ Manages the entire database system

◦ Handles backups, security, tuning, and access control

2. Database Designers:
◦ De ne the logical and physical structure of the database

◦ Create schemas, tables, and constraints

3. Application Programmers:
◦ Write applications that interact with the database

◦ Use APIs and languages like Python, Java, or PHP

4. End Users:
◦ Use applications to query and manipulate data

◦ Can be casual, naïve, or sophisticated users

5. System Analysts:
◦ Bridge the gap between end-users and developers
fi
◦ Analyze requirements and help design solutions

4. Explain the Three-Tier Schema Architecture and Its Signi cance (10 Marks)

The three-tier architecture separates the database into three levels:

1. Internal Level (Physical Schema):


◦ Describes physical storage of data

◦ Focuses on ef ciency and access paths

2. Conceptual Level (Logical Schema):


◦ Represents entire database logically

◦ Describes structure, relationships, and constraints

3. External Level (View Schema):


◦ User-speci c views of the database

◦ Hides irrelevant details from users

Diagram:

[External Views] ↔ [Conceptual Schema] ↔ [Internal Schema]


Signi cance:

• Achieves Data Independence (Logical and Physical)

• Enhances security and abstraction

• Supports multiple user views

5. Different Data Models in DBMS with Examples (10 Marks)

1. Hierarchical Model:
◦ Organizes data in a tree structure

◦ Parent-child relationship

◦ Ex: Organization structure

2. Network Model:
◦ Records connected through links

◦ Supports many-to-many relationships

◦ Ex: Student enrolled in multiple courses


fi
fi
fi
fi
3. Relational Model:
◦ Data stored in tables (relations)

◦ Uses primary and foreign keys

◦ Ex: MySQL, PostgreSQL

4. Entity-Relationship Model (ER Model):


◦ Uses entities, attributes, and relationships

◦ Focuses on design phase

5. Object-Oriented Model:
◦ Integrates object-oriented programming with databases

◦ Stores complex data like multimedia

◦ Ex: DBMS for graphics design

6. ER Diagram for Student-Course Registration System (10 Marks)

Entities:

• Student (StudentID, Name, Email)

• Course (CourseID, CourseName, Credits)

Relationship:

• Registers (DateOfRegistration)

ER Diagram:

Student ── Registers ──> Course


↑ ↓ ↑
[StudentID] [Date] [CourseID]
Explanation:

• A student can register for many courses.

• A course can be registered by many students.

• Registers is a many-to-many relationship.

7. Concepts of Subclass, Superclass, Inheritance, Specialization, and Generalization (10


Marks)

• Superclass: General entity (e.g., Person)

• Subclass: Speci c entities (e.g., Student, Teacher)


fi
• Inheritance: Subclass inherits attributes of superclass

• Specialization: Dividing a general entity into speci c sub-entities

• Generalization: Merging similar entities into a general superclass

Example:

• Superclass: Person (Name, DOB)

• Subclass: Student (RollNo), Teacher (EmployeeID)

ER Representation:

Person
/ \
Student Teacher

8. Advantages of Using DBMS with Real-World Applications (10 Marks)

Advantages:

1. Reduced Redundancy: Avoids duplicate data using normalization

2. Data Integrity: Enforces constraints for accuracy

3. Data Security: Provides access control

4. Concurrent Access: Allows multiple users

5. Backup & Recovery: Automated tools for safety

6. Data Independence: Logical and physical data independence

7. Scalability: Can grow with the business

Real-World Applications:

• Banking Systems: Transactions, accounts, ATM operations

• Healthcare: Patient records, appointments, billing

• E-Commerce: Product catalog, orders, payments

• Education: Student info, course management

• Airline Reservations: Booking and schedule systems


fi
Unit 2

2marks
1. What is a relation in the relational model? Give an example.
A relation is a table with rows and columns used to represent data in the relational model.
Example: A STUDENT table with columns: ID, Name, and Age.

2. De ne the terms: domain, attribute, and tuple.

• Domain: A set of valid values for an attribute.

• Attribute: A column in a table.

• Tuple: A single row in a table.

3. What are null values in a relational database? Why are they important?
Null values represent missing or unknown data.
They help handle optional data and maintain data integrity.

4. State the difference between candidate key and primary key.

• Candidate Key: A set of attributes that uniquely identify tuples.

• Primary Key: A selected candidate key used to uniquely identify tuples in a table.

5. What is a domain constraint in the relational model?


A domain constraint ensures that an attribute's value belongs to a speci c domain (data type or set
of valid values).

6. What is the difference between relational algebra and relational calculus?

• Relational Algebra: Procedural query language specifying how to get data.

• Relational Calculus: Non-procedural query language specifying what data to retrieve.

7. Write the SQL command to create a table named STUDENT with attributes ID, Name, and
Age.

sql
CopyEdit
CREATE TABLE STUDENT (
ID INT,
Name VARCHAR(50),
Age INT
);
fi
fi
8. Write an SQL command to insert a new record into a table named EMPLOYEE.

sql
CopyEdit
INSERT INTO EMPLOYEE (ID, Name, Salary)
VALUES (101, 'John Doe', 50000);

Long answers
1. Explain the basic concepts of the relational model, including domain, attribute, tuple, and
relation. Provide examples.

The relational model is a way of structuring data in tables (relations), where each table is made up
of rows (tuples) and columns (attributes). It is a foundation for relational database management
systems (RDBMS).

• Domain: A domain refers to the set of permissible values for a given attribute. For example,
for the "Age" attribute, the domain might be integers between 0 and 150.

◦ Example: Age → {0, 1, 2, ..., 150}

• Attribute: An attribute is a column in a table. It describes a characteristic or property of an


entity.

◦ Example: In a Student table, the attributes could be ID, Name, Age.

• Tuple: A tuple is a single row in a table, representing a single record.

◦ Example: (1, "Alice", 22) is a tuple in a Student table.

• Relation: A relation is a table consisting of tuples, where each tuple is a record and each
attribute is a column.

◦ Example: A Student table with attributes ID, Name, and Age would be a
relation.

Example Table (Student):

I Ag
Name
D e
1 Alice 22
2 Bob 23
Charli
3 21
e

2. Discuss various types of constraints in the relational model: Domain, Key, and Integrity
constraints. Why are they important?

• Domain Constraints: Ensure that the values in an attribute belong to the speci ed domain.
It restricts the data type or range of values allowed for an attribute.
fi
◦ Example: The Age attribute can only have values between 0 and 150 (domain
constraint).

• Key Constraints: Ensure that each tuple in a relation is uniquely identi able. The primary
key is one or more attributes that uniquely identify a tuple in a relation.

◦ Example: The ID attribute in the Student table can be a primary key because it
uniquely identi es each student.

• Integrity Constraints: Enforce rules to maintain data consistency and validity.

◦ Types of Integrity Constraints:

▪ Entity Integrity: Ensures that no primary key value is NULL.

▪ Referential Integrity: Ensures that foreign keys in one table must match
primary keys in another table.

Importance:

• Data Consistency: Constraints help maintain data accuracy and prevent errors.

• Data Integrity: They ensure that the relationships between tables are logical and correct.

• Reliability: Constraints make sure that data adheres to speci c rules, which reduces the
possibility of invalid or corrupted data.

3. Explain the role and impact of null values in relational databases.

• Role of Null Values: A null value in a relational database represents missing, unknown, or
inapplicable data. It is used when the actual value is not available.
Example: If a Student table has a DateOfGraduation column, a student who
hasn't graduated yet might have a NULL value in this column.

• Impact:

◦ Data Integrity: Null values allow exibility in representing missing data but may
lead to inconsistencies if not handled properly.

◦ Query Complexity: Null values complicate queries because comparisons like


WHERE column = NULL do not return any results. Special SQL syntax (e.g.,
IS NULL) is required to handle null values.

◦ Database Design: The presence of null values can complicate data processing, such
as when aggregating data, performing joins, or calculating averages.

4. Differentiate between relational algebra and relational calculus. Also, discuss their
signi cance in querying databases.
fi
fi
fl
fi
fi
• Relational Algebra: A procedural query language that provides a set of operations (like
SELECT, PROJECT, JOIN) to manipulate relations and retrieve the required data. It de nes
how the result is to be computed.

◦ Example: SELECT Name FROM Student WHERE Age > 21

• Relational Calculus: A non-procedural query language where you specify what data to
retrieve without describing how to get it. It uses mathematical logic to express queries.

◦ Example: {S.Name | ∃A (Student(S) ∧ S.Age > 21)}

Signi cance:

• Relational Algebra: It is closer to how a database engine works and is more ef cient for
optimization. It focuses on step-by-step query execution.

• Relational Calculus: It is more declarative and allows users to express complex queries
without worrying about execution strategy, making it useful for abstract querying.

5. Write SQL statements to create a table, insert records, update a record, and delete a record.
Use a simple database schema like STUDENT or EMPLOYEE.

1. Create a Table:
sql
CopyEdit

CREATE TABLE STUDENT (

2. ID INT PRIMARY KEY,


3. Name VARCHAR(50),
4. Age INT
5. );
6.

7. Insert Records:
sql
CopyEdit

INSERT INTO STUDENT (ID, Name, Age) VALUES (1, 'Alice',


22);

8. INSERT INTO STUDENT (ID, Name, Age) VALUES (2, 'Bob',


23);
9.
fi
fi
fi
10. Update a Record:
sql
CopyEdit

UPDATE STUDENT SET Age = 24 WHERE ID = 2;

11.

12. Delete a Record:


sql
CopyEdit

DELETE FROM STUDENT WHERE ID = 1;

13.

6. De ne relational algebra. Explain at least four basic operations (Select, Project, Union,
Cartesian Product) with examples.

• Relational Algebra: A formal query language that consists of a set of operations used to
retrieve and manipulate data from relational databases.

1. Select (σ): Retrieves rows that satisfy a given condition.

◦ Example: σ(Age > 21)(Student)

◦ Explanation: Selects all students where the age is greater than 21.

2. Project (π): Retrieves speci ed columns (attributes) from a relation.

◦ Example: π(Name)(Student)

◦ Explanation: Projects the Name column from the Student table.

3. Union (∪): Combines the results of two relations, removing duplicates.

◦ Example: Student ∪ Teacher

◦ Explanation: Combines all students and teachers into one set.

4. Cartesian Product (×): Combines two relations into a new relation with every combination
of rows.

◦ Example: Student × Course

◦ Explanation: Returns all possible combinations of students and courses.


fi
fi
7. What is relational calculus? Explain the difference between Tuple Relational Calculus
(TRC) and Domain Relational Calculus (DRC) with examples.

• Relational Calculus: A declarative query language that speci es what to retrieve without
de ning how to retrieve it. It uses logical expressions to de ne queries.

• Tuple Relational Calculus (TRC): Speci es the query as a set of tuples.

◦ Example: {T.Name | ∃S (Student(S) ∧ S.Age > 21 ∧


S.Name = T.Name)}

◦ Explanation: Selects the names of students older than 21.

• Domain Relational Calculus (DRC): Speci es the query as a set of values from the
domain of the attributes.

◦ Example: {S.Name | ∃Age (Student(S) ∧ S.Age > 21)}

◦ Explanation: Selects the names of students older than 21.

Difference:

• TRC refers to entire tuples (rows), while DRC refers to individual attribute values.

8. Design a simple relational database schema for a library system. Include table de nitions,
constraints, and sample SQL commands for data manipulation.

Tables:

1. Book: Contains book details.


sql
CopyEdit

CREATE TABLE Book (

2. BookID INT PRIMARY KEY,


3. Title VARCHAR(100),
4. Author VARCHAR(50),
5. Genre VARCHAR(30)
6. );
7.

8. Member: Contains member details.


sql
CopyEdit
fi
fi
fi
fi
fi
fi
CREATE TABLE Member (

9. MemberID INT PRIMARY KEY,


10. Name VARCHAR(50),
11. JoinDate DATE
12. );
13.

14. Loan: Links members to the books they borrow.


sql
CopyEdit

CREATE TABLE Loan (

15. LoanID INT PRIMARY KEY,


16. MemberID INT,
17. BookID INT,
18. LoanDate DATE,
19. DueDate DATE,
20. FOREIGN KEY (MemberID) REFERENCES Member(MemberID),
21. FOREIGN KEY (BookID) REFERENCES Book(BookID)
22. );
23.

Sample SQL Commands:

1. Insert Book:
sql
CopyEdit

INSERT INTO Book (BookID, Title, Author, Genre) VALUES


(1, 'The Great Gatsby', 'F. Scott Fitzgerald',
'Fiction');

2.

3. Insert Member:
sql
CopyEdit
INSERT INTO Member (MemberID, Name, JoinDate) VALUES
(101, 'John Doe', '2023-04-15');

4.

5. Insert Loan:
sql
CopyEdit

INSERT INTO Loan (LoanID, MemberID, BookID, LoanDate,


DueDate) VALUES (1001,
Unit- 3
1. Write an SQL query using a WHERE clause to find employees with a salary greater than 50000.
sql
CopyEdit
SELECT * FROM Employee
WHERE Salary > 50000;
This query selects all records from the Employee table where the salary is greater than 50,000.

2. What is the difference between WHERE and HAVING clauses in SQL?

• WHERE Clause: The WHERE clause is used to lter records before any grouping occurs. It
is used to lter rows based on a condition.

◦ Example: SELECT * FROM Employee WHERE Salary > 50000;

• HAVING Clause: The HAVING clause is used to lter records after grouping has been
applied (i.e., it is used with aggregate functions like COUNT, SUM, AVG).

◦ Example: SELECT Department, AVG(Salary) FROM Employee


GROUP BY Department HAVING AVG(Salary) > 50000;

3. Name any two SQL Date and Time functions with their use.

1. NOW(): Returns the current date and time.


◦ Example: SELECT NOW();

◦ Use: To get the current system date and time.

2. DATE_ADD(): Adds a speci ed time interval to a date.


◦ Example: SELECT DATE_ADD('2025-04-24', INTERVAL 5
DAY);
◦ Use: To add a speci ed number of days, months, or years to a date.

4. What is a subquery in SQL? Give an example.

A subquery is a query nested inside another query, usually in the WHERE, FROM, or SELECT
clause. It allows for more complex ltering or computation within the main query.

Example:

sql
CopyEdit
SELECT Name FROM Employee
WHERE Salary > (SELECT AVG(Salary) FROM Employee);
This query nds employees whose salary is greater than the average salary in the Employee
table.
fi
fi
fi
fi
fi
fi
fi
5. List any two aggregate functions in SQL and explain brie y.

1. COUNT(): Returns the number of rows that match the speci ed condition.
◦ Example: SELECT COUNT(*) FROM Employee WHERE
Department = 'HR';
◦ Explanation: Returns the count of employees in the HR department.

2. AVG(): Returns the average value of a numeric column.


◦ Example: SELECT AVG(Salary) FROM Employee;

◦ Explanation: Calculates the average salary of all employees.

6. What is the purpose of the GROUP BY clause in SQL?

The GROUP BY clause is used to arrange identical data into groups based on one or more
columns. It is commonly used with aggregate functions like COUNT(), SUM(), AVG(), etc., to
perform calculations on each group of records.

Example:

sql
CopyEdit
SELECT Department, AVG(Salary) FROM Employee
GROUP BY Department;
This query groups employees by department and calculates the average salary for each department.

7. De ne an updatable view. How is it different from a non-updatable view?

• Updatable View: An updatable view allows data modi cations (such as INSERT,
UPDATE, or DELETE) on the view, which are re ected in the underlying base table. The
view must directly reference a single table and have no complex calculations or joins.

◦ Example: A view based on a single table like Employee.

• Non-updatable View: A non-updatable view does not allow modi cations because it may
involve multiple tables, joins, or complex calculations that make it impossible to map the
changes back to the underlying tables.

◦ Example: A view combining data from multiple tables with joins and aggregates.

8. Write the syntax of an INNER JOIN and brie y explain its purpose.

Syntax:

sql
CopyEdit
fi
fl
fl
fi
fi
fl
fi
SELECT columns
FROM table1
INNER JOIN table2
ON table1.column = table2.column;
Purpose: The INNER JOIN is used to retrieve records that have matching values in both tables.
It only returns rows where there is a match in both tables based on the condition speci ed in the ON
clause.

Example:

sql
CopyEdit
SELECT Employee.Name, Department.Name
FROM Employee
INNER JOIN Department
ON Employee.DepartmentID = Department.ID;
This query returns the names of employees and the names of their departments, only where there is
a match between the Employee and Department tables.

Long Answers
1. Write SQL queries to demonstrate the use of SELECT and PROJECT
operations along with arithmetic and logical conditions. Include the WHERE
clause.

• SELECT Operation: This operation retrieves data from one or more columns.

• PROJECT Operation: This operation retrieves speci c columns, eliminating duplicates if


necessary.

Example:

sql
CopyEdit
-- SELECT operation: Retrieves all columns from the Employee
table where salary is greater than 50000
SELECT * FROM Employee
WHERE Salary > 50000;

-- PROJECT operation: Retrieves only Name and Salary columns


from the Employee table
SELECT Name, Salary FROM Employee
WHERE Department = 'HR' AND Salary > 50000;

-- Arithmetic condition: Retrieves employees with salary


after a 10% raise
SELECT Name, Salary, Salary * 1.10 AS NewSalary FROM
Employee;
fi
fi
-- Logical condition: Retrieves employees who are in either
'HR' or 'Finance' department with salary greater than 50000
SELECT Name, Department, Salary
FROM Employee
WHERE Department IN ('HR', 'Finance') AND Salary > 50000;

2. Explain different SQL functions: Date/Time, Numeric, and String Conversion


functions with examples.

Date/Time Functions:

1. NOW(): Returns the current date and time.


sql
CopyEdit

SELECT NOW();

2.

3. DATE_ADD(): Adds a speci ed time interval to a date.


sql
CopyEdit

SELECT DATE_ADD('2025-04-24', INTERVAL 5 DAY);

4.

Numeric Functions:

1. ROUND(): Rounds a numeric value to a speci ed number of decimal places.


sql
CopyEdit

SELECT ROUND(123.4567, 2); -- Output: 123.46

2.

3. CEIL(): Returns the smallest integer greater than or equal to the numeric value.
sql
CopyEdit
fi
fi
SELECT CEIL(123.45); -- Output: 124

4.

String Conversion Functions:

1. CAST(): Converts one data type to another.


sql
CopyEdit

SELECT CAST(123 AS CHAR); -- Converts integer 123 to


string

2.

3. CONVERT(): Similar to CAST, used for type conversion.


sql
CopyEdit

SELECT CONVERT('2025-04-24', DATE);

4.

3. Describe how to create tables with relationships in SQL. How do you


implement key and integrity constraints?

Creating Tables with Relationships:

• Primary Key: Uniquely identi es each record in a table.

• Foreign Key: Enforces a relationship between two tables.

Example:

sql
CopyEdit
-- Create Employee Table
CREATE TABLE Employee (
EmployeeID INT PRIMARY KEY,
Name VARCHAR(50),
fi
DepartmentID INT
);

-- Create Department Table


CREATE TABLE Department (
DepartmentID INT PRIMARY KEY,
DepartmentName VARCHAR(50)
);

-- Implement Foreign Key Constraint


ALTER TABLE Employee
ADD CONSTRAINT FK_Department
FOREIGN KEY (DepartmentID) REFERENCES
Department(DepartmentID);
Key Constraints:

• Primary Key: Uniquely identi es each row in a table.

• Foreign Key: Ensures referential integrity by enforcing relationships between tables.

4. What are nested queries and subqueries in SQL? Write examples showing
both correlated and non-correlated subqueries.

Nested Queries/Subqueries: A subquery is a query inside another query. It can be correlated or


non-correlated.

• Non-Correlated Subquery: The inner query is independent of the outer query.


Example:
sql
CopyEdit

SELECT Name FROM Employee

• WHERE Salary > (SELECT AVG(Salary) FROM Employee);


• Correlated Subquery: The inner query refers to columns from the outer query.
Example:
sql
CopyEdit

SELECT Name FROM Employee e


fi
• WHERE Salary > (SELECT AVG(Salary) FROM Employee WHERE
DepartmentID = e.DepartmentID);

5. Discuss SQL clauses used for grouping, aggregation, and ordering of records.
Support your answer with SQL examples.

• GROUP BY: Groups rows that have the same values into summary rows, often used with
aggregate functions.

• HAVING: Filters groups based on a condition.

• ORDER BY: Sorts the result set based on speci ed columns.

Example:

sql
CopyEdit
-- Grouping and Aggregation
SELECT Department, COUNT(*) AS NumEmployees, AVG(Salary) AS
AvgSalary
FROM Employee
GROUP BY Department
HAVING AVG(Salary) > 50000; -- Filter groups where avg
salary is greater than 50000

-- Ordering results
SELECT Name, Salary
FROM Employee
ORDER BY Salary DESC; -- Sorts employees by salary in
descending order

6. Explain various types of SQL JOINS with syntax and examples: INNER
JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN.

• INNER JOIN: Returns rows when there is a match in both tables.


Example:
sql
CopyEdit

SELECT Employee.Name, Department.DepartmentName

• FROM Employee
fi
• INNER JOIN Department ON Employee.DepartmentID =
Department.DepartmentID;

• LEFT JOIN: Returns all rows from the left table and matched rows from the right table. If
no match, NULL is returned for right table.
Example:
sql
CopyEdit

SELECT Employee.Name, Department.DepartmentName

• FROM Employee
• LEFT JOIN Department ON Employee.DepartmentID =
Department.DepartmentID;

• RIGHT JOIN: Returns all rows from the right table and matched rows from the left table.
If no match, NULL is returned for left table.
Example:
sql
CopyEdit

SELECT Employee.Name, Department.DepartmentName

• FROM Employee
• RIGHT JOIN Department ON Employee.DepartmentID =
Department.DepartmentID;

• FULL OUTER JOIN: Returns all rows when there is a match in either the left or right
table. Non-matching rows from both sides are returned with NULL.
Example:
sql
CopyEdit

SELECT Employee.Name, Department.DepartmentName

• FROM Employee
• FULL OUTER JOIN Department ON Employee.DepartmentID =
Department.DepartmentID;

7. What are SQL views? Differentiate between updatable and non-updatable


views with examples. How are views created and used?

• SQL Views: A view is a virtual table created by a query on one or more tables. It can
simplify complex queries and enhance security by restricting access to certain columns or
rows.

• Updatable Views: A view that allows for INSERT, UPDATE, and DELETE operations.
Example:
sql
CopyEdit

CREATE VIEW EmployeeView AS

• SELECT EmployeeID, Name, Salary FROM Employee;



• -- You can update EmployeeView because it is simple and
refers to a single table

• Non-Updatable Views: A view that does not allow direct modi cation. Typically used when
the view involves multiple tables, joins, or aggregate functions.
Example:
sql
CopyEdit

CREATE VIEW DepartmentView AS

• SELECT DepartmentName, AVG(Salary) AS AvgSalary


• FROM Employee
• GROUP BY DepartmentName;

• -- You cannot update DepartmentView because it involves
aggregation

8. Explain relational set operations in SQL with examples: UNION,


INTERSECT, and EXCEPT. How are they different from JOINS?
fi
• UNION: Combines the results of two queries, eliminating duplicates.
Example:
sql
CopyEdit

SELECT Name FROM Employee

• UNION
• SELECT Name FROM Contractor;

• INTERSECT: Returns the common records from two queries.


Example:
sql
CopyEdit

SELECT Name FROM Employee

• INTERSECT
• SELECT Name FROM Contractor;

• EXCEPT: Returns the records from the rst query that do not exist in the second query.
Example:
sql
CopyEdit

SELECT Name FROM Employee

• EXCEPT
• SELECT Name FROM Contractor;

Difference from JOINS:

• JOINS are used to combine rows from two or more tables based on a related column.

• Set operations (UNION, INTERSECT, EXCEPT) are used to combine or subtract result
sets from two queries.
fi
Unit- 4
2 marks
1. What is the main purpose of normalization in database design?

Normalization is the process of organizing the attributes and tables of a relational database to
minimize redundancy and dependency. The main purpose is to:

• Eliminate data redundancy: Redundant data is stored in multiple places, leading to wasted
storage and potential inconsistencies.

• Ensure data integrity: By breaking down complex tables into smaller, manageable ones,
normalization helps maintain consistency and integrity.

• Simplify queries: Normalized data is easier to query as it removes unnecessary duplicates


and unnecessary relationships.

2. De ne functional dependency with an example.

Functional Dependency (FD) is a relationship between two attributes or sets of attributes in a


relational database. In functional dependency, one attribute (or group of attributes) uniquely
determines another attribute.

Example: In a table Employee (EmpID, Name, Salary), we can say that:

• EmpID → Name (EmpID determines the Name)

• EmpID → Salary (EmpID determines the Salary)

This means that for each EmpID, there will be only one corresponding Name and Salary.

3. What is a surrogate key? When is it used?

A surrogate key is a unique identi er for a table record that is not derived from the application
data. It is typically a system-generated value, such as an integer or GUID (Globally Unique
Identi er).

When is it used?

• It is used when no natural key (i.e., an attribute that uniquely identi es a record in the real
world) is suitable or when a natural key is too complex.

• Surrogate keys are commonly used in situations where the natural key may change over
time, such as in cases where customer data is updated regularly, and the primary key would
need to be updated as well.

Example: A table Employee (EmployeeID, FirstName, LastName) could use a


surrogate key EmployeeID that is a unique system-generated integer, instead of using a
composite key like (FirstName, LastName).
fi
fi
fi
fi
4. What is the difference between 1NF and 2NF?

• 1NF (First Normal Form): A relation is in 1NF if it has only atomic (indivisible) values
and each record is unique. No repeating groups or arrays are allowed.
Example:
plaintext
CopyEdit

Employee (EmpID, Name, PhoneNumbers)

In this example, PhoneNumbers could store multiple phone numbers for each employee,
which violates 1NF.
• 2NF (Second Normal Form): A relation is in 2NF if it is in 1NF and all non-key attributes
are fully dependent on the primary key. In other words, it removes partial dependency,
where non-key attributes depend only on part of a composite primary key.
Example:
plaintext
CopyEdit

OrderDetails (OrderID, ProductID, ProductPrice)

If OrderID and ProductID together form the primary key, and ProductPrice
depends only on ProductID, then ProductPrice is partially dependent on part of
the primary key, violating 2NF.

5. De ne lossless join decomposition. Why is it important?

Lossless Join Decomposition refers to the process of breaking down a relation into smaller sub-
relations in such a way that, when they are joined back, the original relation can be perfectly
reconstructed without any loss of data.

Importance:

• It ensures that no data is lost during the decomposition process.

• It guarantees that the decomposed relations still provide the original information when
joined together.
Example: Decomposing a table Employee (EmpID, Name, DeptID,
DeptName) into two tables Employee (EmpID, Name, DeptID) and
Department (DeptID, DeptName) maintains the original data when the two are
joined back.
fi
6. What is Boyce-Codd Normal Form (BCNF)?

Boyce-Codd Normal Form (BCNF) is a higher version of the 3NF. A relation is in BCNF if, for
every functional dependency X → Y, the determinant X is a superkey.

• Superkey: A set of attributes that can uniquely identify a tuple.

• BCNF eliminates situations where a non-prime attribute is functionally dependent on a part


of a candidate key.

Example: Consider the table CourseInstructor (CourseID, Instructor,


Room). If Instructor → Room (an instructor determines the room), this violates BCNF
because Instructor is not a superkey.

7. What is a multivalued dependency (MVD)?

A Multivalued Dependency (MVD) occurs when one attribute or set of attributes in a table
uniquely determines a set of values for another attribute, independent of other attributes. It is a type
of dependency that occurs when an attribute is dependent on a set of attributes, but not on a single
attribute.

Example: Consider a table Student (StudentID, Subject, Hobby) where:

• A student can have multiple subjects and multiple hobbies.

• The MVD would be: StudentID →→ Subject and StudentID →→ Hobby.

This means that for each StudentID, the set of Subjects and the set of Hobbies are
independent, and each can have multiple values.

8. What is meant by dependency preserving decomposition?

Dependency Preserving Decomposition refers to the property of a decomposition where all


functional dependencies are preserved in the resulting sub-relations. This ensures that no functional
dependency is lost when decomposing a relation into multiple smaller relations.

Importance:

• It ensures that the original set of functional dependencies can still be enforced after the
decomposition, making the database easier to maintain and ensuring that the integrity
constraints are preserved.

• Helps in enforcing the correct constraints while performing queries and updates on the
decomposed tables.
Long Answers

1. Explain the concept of normalization. Why is it needed in relational database


design?

Normalization is a systematic approach to organizing data in a relational database to minimize


redundancy and dependency by dividing large tables into smaller ones and de ning relationships
between them. The main goal is to ensure that the database structure is both ef cient and free from
anomalies during insert, update, and delete operations.

Need for Normalization:

• Reduce Redundancy: Repeating groups of data lead to inef cient storage and increased
risk of data inconsistency.

• Improve Data Integrity: By minimizing redundancy, normalization reduces the risk of data
anomalies and ensures that data is consistent and accurate.

• Optimize Queries: A normalized database structure results in faster, more ef cient queries
as data is more logically organized.

2. De ne functional dependency. Explain how it is used to determine normal


forms with a suitable example.

A functional dependency (FD) in a relational database is a relationship where one attribute or a


group of attributes uniquely determines another attribute. If attribute X functionally determines
attribute Y, it is denoted as X → Y, meaning for each unique value of X, there will be a
corresponding unique value of Y.

Example:

Consider the table Employee (EmpID, EmpName, DeptID, DeptName):

• EmpID → EmpName (EmpID determines EmpName)

• DeptID → DeptName (DeptID determines DeptName)

Using FDs to determine normal forms:

• 1NF (First Normal Form): Ensures that each attribute contains atomic (indivisible) values.
It eliminates repeating groups.

• 2NF (Second Normal Form): Ensures that a table is in 1NF and that all non-key attributes
are fully functionally dependent on the entire primary key (eliminates partial dependency).

• 3NF (Third Normal Form): Ensures that a table is in 2NF and that no transitive
dependencies exist (i.e., non-key attributes should not depend on other non-key attributes).
fi
fi
fi
fi
fi
3. Describe 1NF, 2NF, and 3NF with examples. How does each normal form
eliminate redundancy?

1NF (First Normal Form):

A relation is in 1NF if all the columns contain atomic (indivisible) values, and each record is
unique. No repeating groups or arrays should be present.

Example:

plaintext
CopyEdit
Employee(EmpID, EmpName, PhoneNumbers)
In this example, PhoneNumbers could contain multiple numbers for each employee, violating
1NF. To bring it to 1NF:

plaintext
CopyEdit
Employee(EmpID, EmpName, PhoneNumber)
This ensures that each PhoneNumber is atomic.

2NF (Second Normal Form):

A table is in 2NF if it is in 1NF and all non-key attributes are fully functionally dependent on the
entire primary key. It eliminates partial dependency, where a non-key attribute depends only on
part of a composite key.

Example:

plaintext
CopyEdit
OrderDetails(OrderID, ProductID, ProductName, Quantity)
If OrderID and ProductID are the primary key, ProductName depends only on
ProductID, which violates 2NF. To bring it to 2NF:

plaintext
CopyEdit
OrderDetails(OrderID, ProductID, Quantity)
Product(ProductID, ProductName)
3NF (Third Normal Form):

A table is in 3NF if it is in 2NF and contains no transitive dependencies, meaning non-key


attributes should not depend on other non-key attributes.

Example:

plaintext
CopyEdit
Employee(EmpID, EmpName, DeptID, DeptHead)
Here, DeptHead depends on DeptID, which is a non-key attribute, violating 3NF. To bring it to
3NF:

plaintext
CopyEdit
Employee(EmpID, EmpName, DeptID)
Department(DeptID, DeptHead)
This eliminates the transitive dependency between DeptID and DeptHead.

4. What is a surrogate key? Discuss its advantages and disadvantages with


examples.

A surrogate key is a unique identi er for a record in a table that has no meaningful relationship to
the data in the table. It is typically generated by the database system, often using an auto-
incremented number or a GUID.

Advantages of Surrogate Key:

• Simpli es Key Structure: Surrogate keys provide a simple, unique identi er, avoiding
complex or composite keys.

• Improves Performance: As surrogate keys are typically small, they reduce the storage
space and improve query performance.

• Preserves Data Integrity: Surrogate keys ensure that the identity of a record is independent
of the business logic.

Example: Instead of using a composite key like (FirstName, LastName), you can use a
surrogate key like EmployeeID.

Disadvantages of Surrogate Key:

• Lack of Business Meaning: Surrogate keys don’t carry any business meaning, making it
dif cult for users to understand the data.

• Potential for Redundancy: If the surrogate key is used across many tables, the relationship
between tables may be harder to understand.

5. Explain the Boyce-Codd Normal Form (BCNF). How does it differ from 3NF?
Provide an example to show a relation that is in 3NF but not in BCNF.

Boyce-Codd Normal Form (BCNF) is a stricter version of 3NF. A relation is in BCNF if, for every
functional dependency X → Y, the determinant X is a superkey (a set of attributes that uniquely
identi es a tuple in a relation).

Difference Between BCNF and 3NF:


fi
fi
fi
fi
fi
• 3NF allows a non-prime attribute (a non-key attribute) to depend on another non-prime
attribute (transitive dependency) as long as it doesn’t violate the functional dependency.

• BCNF eliminates such situations by ensuring that every determinant is a superkey.

Example: Consider the relation Student(CourseID, Instructor, Room) where:

• CourseID → Instructor (CourseID determines Instructor)

• Instructor → Room (Instructor determines Room)

Here, Instructor is not a superkey, so the relation is in 3NF but not in BCNF. To bring it into
BCNF, we decompose it into two relations:

plaintext
CopyEdit
Student(CourseID, Instructor)
InstructorRoom(Instructor, Room)

6. Discuss the importance of lossless join and dependency preservation in


schema decomposition. Use an example to illustrate both.

Lossless Join Decomposition ensures that the original relation can be reconstructed by performing
a natural join of the decomposed relations. This prevents the loss of any data during decomposition.

Dependency Preservation ensures that all functional dependencies are maintained in the
decomposed relations.

Example:

Consider a relation Student(StuID, Name, CourseID, Instructor) with the


following dependencies:

• StuID → Name

• CourseID → Instructor

If we decompose it into:

plaintext
CopyEdit
Student1(StuID, Name, CourseID)
Student2(CourseID, Instructor)
• The join of Student1 and Student2 gives back the original relation, so the
decomposition is lossless.

• All dependencies are preserved in Student1 and Student2, so the decomposition is


dependency-preserving.
7. What is a multivalued dependency? Explain the concept of 4NF and how it
addresses multivalued dependencies.

A multivalued dependency (MVD) occurs when one attribute or set of attributes determines
another set of attributes independently of other attributes in the relation.

4NF (Fourth Normal Form):

A relation is in 4NF if it is in Boyce-Codd Normal Form (BCNF) and has no multivalued


dependencies. In 4NF, a multivalued dependency is eliminated by creating separate relations.

Example: Consider the table Student(StuID, Subject, Hobby):

• A student can have multiple subjects and multiple hobbies.

• StuID →→ Subject and StuID →→ Hobby are multivalued dependencies.

To bring this to 4NF:

plaintext
CopyEdit
StudentSubject(StuID, Subject)
StudentHobby(StuID, Hobby)

8. De ne 5NF (Fifth Normal Form) with an example. In what scenarios is 5NF


particularly useful?

5NF (Fifth Normal Form), also called Projection-Join Normal Form (PJNF), is a normal form
in which a relation is decomposed in such a way that it cannot be further decomposed without
losing information. A relation is in 5NF if every join dependency in the relation is implied by the
candidate keys.

Example:

Consider the table ProjectEmployee(ProjID, EmpID, Skill):

• An employee may work on multiple projects and may have multiple skills.

• If each skill is tied to each project and employee, this can lead to redundant data.

To decompose it into 5NF:

plaintext
CopyEdit
Project(ProjID, EmpID)
EmployeeSkill(EmpID, Skill)
5NF is particularly useful when complex relationships exist, and eliminating redundancy without
losing data requires a detailed decomposition of the data.
fi
Unit-5
2 marks
1. What are the different states of a transaction?

The states of a transaction are:

1. Active: The transaction is being executed.

2. Partially Committed: The transaction has completed execution, but changes are not yet
permanent.

3. Committed: The transaction has successfully completed, and changes are permanent.

4. Failed: The transaction encountered an error and could not complete.

5. Aborted: The transaction was rolled back and no changes are made.

2. De ne the ACID properties in database transactions.

The ACID properties ensure reliable transaction processing in a DBMS:

1. Atomicity: A transaction is treated as a single unit; it either fully completes or is entirely


rolled back.

2. Consistency: The database moves from one consistent state to another after a transaction.

3. Isolation: Transactions are isolated from each other; the intermediate state of a transaction is
not visible to others.

4. Durability: Once a transaction is committed, its changes are permanent, even in case of a
system failure.

3. What is serializability in the context of transaction execution?

Serializability ensures that the concurrent execution of transactions results in a database state
equivalent to some serial (non-interleaved) execution of those transactions. This ensures
consistency, as if the transactions were executed one after another, without interference.

4. What is the difference between deadlock and starvation in transactions?

• Deadlock: Occurs when two or more transactions are waiting for each other to release
resources, causing a cycle of waiting where none of the transactions can proceed.

• Starvation: Happens when a transaction is perpetually delayed because other transactions


are constantly given priority, preventing it from completing.

5. What is the purpose of using locks in concurrency control?


fi
Locks are used to control access to database resources by multiple transactions to ensure data
consistency and avoid con icts. Locks prevent other transactions from accessing data that is being
modi ed, ensuring the isolation property of ACID.

6. De ne a B+ Tree and mention its primary use in databases.

A B+ Tree is a self-balancing tree data structure that maintains sorted data and allows ef cient
insertion, deletion, and search operations. Its primary use in databases is for indexing, allowing
quick data retrieval.

7. What is optimistic concurrency control?

Optimistic concurrency control assumes that multiple transactions can complete without
interfering with each other. It allows transactions to execute without locks, but before committing, it
checks if there were any con icting operations during the transaction's execution. If a con ict is
found, the transaction is rolled back.

8. List any two types of failure classi cations in DBMS.

1. Transaction Failure: Occurs when a transaction encounters an error, such as violation of


constraints or resource unavailability.

2. System Crash: Happens when the DBMS or hardware crashes unexpectedly, causing data
loss or inconsistencies.

Long answers

1. ACID Properties in Database Transactions

The ACID properties are the foundation of reliable database transactions, ensuring that database
operations are executed in a consistent and secure manner.

1.1 Atomicity

• De nition: A transaction is considered atomic, meaning it is indivisible. It is either fully


completed or not executed at all.

• Example: In a bank transfer, if a transaction deducts money from one account but fails to
add it to another, the entire transaction is rolled back to maintain consistency. No money is
lost.

• Importance: Atomicity ensures that partial or incomplete transactions don't leave the
database in an inconsistent state.

1.2 Consistency

• De nition: A transaction must bring the database from one consistent state to another,
adhering to all de ned constraints (e.g., uniqueness, foreign keys).
fi
fi
fi
fi
fi
fl
fl
fi
fi
fl
• Example: In a student enrollment system, if a transaction adds a record for a student, it
should ensure that the student ID is unique, and no other student has the same ID.

• Importance: It guarantees that the database maintains integrity by following all de ned
rules.

1.3 Isolation

• De nition: Transactions should not interfere with each other. Even if transactions are
executed concurrently, their results should be as if they were executed serially.

• Example: If two transactions are transferring money between accounts, they should not see
partial or con icting results. One transaction should not be affected by the other until it is
complete.

• Importance: Isolation ensures that one transaction's work is not disrupted by others,
preventing inconsistencies like dirty reads.

1.4 Durability

• De nition: Once a transaction is committed, its changes are permanent, even in the event of
a system failure (e.g., power loss, crash).

• Example: After transferring funds, even if the system crashes, the transaction's changes are
not lost because they have been recorded in stable storage (e.g., disk).

• Importance: Durability guarantees that once a transaction is committed, the changes are
never lost, making the database resilient to failures.

2. Concept of Serializability

Serializability refers to the ability to ensure that concurrent execution of transactions produces the
same result as if the transactions were executed one by one, i.e., serially.

2.1 Con ict Serializability

• De nition: A schedule is con ict serializable if it can be transformed into a serial schedule
by swapping non-con icting operations (operations that do not operate on the same data
item).

• Example:

◦ Transaction 1: T1: Read(A), Write(A)

◦ Transaction 2: T2: Read(B), Write(B)

◦ Schedule: T1: Read(A), T2: Read(B), T1: Write(A), T2: Write(B)

◦ The above schedule is con ict serializable because the operations on A and B do not
interfere with each other and can be swapped.

2.2 View Serializability


fi
fi
fi
fl
fl
fl
fl
fl
fi
• De nition: A schedule is view serializable if it produces the same results as a serial
execution, where the nal state of the database is the same, even if the schedule is not
con ict serializable.

• Example: If transactions access different data items or read/write the same data item in a
different order but still produce the same result, it is considered view serializable.

3. Concurrency Control Protocols

Concurrency control is used to manage the simultaneous execution of transactions while


maintaining the consistency of the database.

3.1 Lock-based Protocols

• De nition: In lock-based protocols, transactions acquire locks before accessing data. Two
main types of locks:

◦ Shared Lock (S-lock): Allows read access to a data item.

◦ Exclusive Lock (X-lock): Allows both read and write access to a data item.

• Example: If T1 locks a data item A with an exclusive lock, T2 must wait until T1 releases
the lock before accessing A.

3.2 Timestamp-based Protocols

• De nition: Each transaction is given a timestamp. The transactions are executed based on
their timestamps, ensuring that older transactions are given precedence.

• Example: If T1 has a timestamp earlier than T2, then T1 must complete its read and write
operations before T2starts.

3.3 Optimistic Protocols

• De nition: In optimistic concurrency control, transactions are allowed to execute without


any locks. Before committing, the system checks for con icts between the transactions.

• Example: A transaction performs its operations, then checks whether any other transactions
have modi ed the data. If con icts are found, the transaction is rolled back.

4. Types of Transaction Failures and Recovery

Transactions can fail due to various reasons, such as system crashes, disk failures, or transaction
errors. Recovery techniques ensure that the database remains in a consistent state.

4.1 Types of Transaction Failures

• Transaction Failure: When a transaction encounters an error (e.g., violates a constraint).

• System Crash: The DBMS crashes while processing transactions.


fi
fi
fi
fi
fl
fi
fi
fl
fl
• Disk Failure: Data loss due to issues in the storage device.

4.2 Recovery Algorithm

• Log-based Recovery: A log records every transaction and its changes. After a failure, the
system uses the log to undo incomplete transactions or redo committed transactions.

• Checkpointing: The system periodically saves the state of the database, which can speed up
recovery.

5. Deadlock in DBMS

A deadlock occurs when two or more transactions are waiting inde nitely for each other to release
resources, causing a cycle.

5.1 Deadlock Detection

• Technique: The DBMS periodically checks for cycles in the transaction wait-for graph to
detect deadlocks. If a cycle is detected, transactions involved in the cycle are aborted.

5.2 Deadlock Prevention

• Technique: Deadlock prevention involves ensuring that transactions acquire all necessary
locks at once, or they follow a strict ordering to avoid cycles in the wait-for graph.

6. Recoverability in Transaction Processing

Recoverability ensures that a transaction's changes are consistent and can be safely rolled back if
needed.

6.1 Cascading Rollback

• De nition: When a transaction fails, all dependent transactions must also be rolled back,
which can lead to a cascading effect if there are multiple dependent transactions.

6.2 Prevention of Cascading Rollback

• Technique: To prevent cascading rollbacks, a strict two-phase commit protocol can be


used, ensuring that transactions only depend on committed transactions.

7. Structure of a B+ Tree

A B+ Tree is a self-balancing tree structure used for indexing in databases. It stores data in leaf
nodes, with internal nodes only used for navigation.

7.1 Insertion

• Steps:
fi
fi
1. Traverse the tree to nd the appropriate leaf node.

2. Insert the key into the leaf node.

3. If the leaf node is full, split it and propagate the split upwards.

7.2 Deletion

• Steps:

4. Find the key in the leaf node.

5. Remove the key.

6. If the leaf node becomes under lled, borrow a key from a sibling or merge with a
sibling.

8. Hash-based Indexing vs Tree-based Indexing

8.1 Hash-based Indexing

• De nition: Uses a hash function to map data to a speci c location in the index. It is optimal
for equality searches.

• Example: A hash index on employee IDs will quickly locate an employee’s data.

8.2 Tree-based Indexing

• De nition: Uses a tree structure (e.g., B+ Tree) to index data. It supports ef cient range
queries and ordering.

• Example: A tree-based index on employee salaries allows ef cient range queries, such as
nding employees earning between $50,000 and $100,000.

8.3 Differences

• Hash-based indexing is best suited for exact match queries (= or IN).

• Tree-based indexing is preferred for range queries (BETWEEN, >, <).


fi
fi
fi
fi
fi
fi
fi
fi

You might also like