0% found this document useful (0 votes)
10 views55 pages

Dbms

The document provides an overview of relational databases, covering their purpose, data models, architecture, and SQL fundamentals. It also discusses database design concepts such as the Entity-Relationship model, normalization, and transaction management principles including ACID properties. Advanced topics include distributed databases, NOSQL databases, and implementation techniques like RAID and indexing.

Uploaded by

Mrsselvam
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)
10 views55 pages

Dbms

The document provides an overview of relational databases, covering their purpose, data models, architecture, and SQL fundamentals. It also discusses database design concepts such as the Entity-Relationship model, normalization, and transaction management principles including ACID properties. Advanced topics include distributed databases, NOSQL databases, and implementation techniques like RAID and indexing.

Uploaded by

Mrsselvam
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/ 55

UNIT I: Relational Databases

1. Purpose of Database Systems:

o Why databases? Databases provide a systematic way to

store, manage, and retrieve data efficiently. They are used to

maintain consistency, integrity, and security in large

amounts of data.

o Use cases: Financial systems, customer databases, social

media platforms, etc.

2. Views of Data:

o External view: The way data is presented to the user (user

interfaces, reports, etc.).

o Conceptual view: How data is structured and stored (logical

structure without worrying about physical storage).

o Internal view: The physical storage of data in files, memory,

etc.

3. Data Models:

o These define the structure of the database. Common models

include:

 Relational model: Data is represented in tables.

 Object-oriented model: Data is represented as objects

(similar to OOP).

 Hierarchical model: Data is organized in a tree-like

structure.

1
 Network model: Data is stored in a graph structure

with nodes and links.

4. Database System Architecture:

o 1-tier: Data stored directly on a computer.

o 2-tier: Clients interact directly with the database.

o 3-tier: An intermediate layer (application server) between

client and database for scalability and security.

5. Introduction to Relational Databases:

o A relational database stores data in tables (also called

relations), each table consisting of rows (tuples) and columns

(attributes).

6. Relational Model:

o The foundation of relational databases, where data is

organized into relations (tables). The relationships between

data are established using keys.

7. Keys:

o Primary Key: A unique identifier for each record in a table.

o Foreign Key: A key used to link two tables.

o Candidate Key: A set of columns that could uniquely identify

a record.

o Super Key: A set of columns that can uniquely identify a

record (might include unnecessary columns).

2
8. Relational Algebra:

o A procedural query language for working with relations

(tables) in a database.

o Operations include:

 SELECT: Retrieves specific rows.

 PROJECT: Retrieves specific columns.

 JOIN: Combines rows from two or more tables based on

related columns.

 UNION, INTERSECTION, DIFFERENCE: Set

operations.

9. SQL Fundamentals:

o SQL (Structured Query Language) is used for querying and

managing relational databases.

o SELECT: Retrieves data.

o INSERT, UPDATE, DELETE: Modify data.

o CREATE, ALTER, DROP: Manage schema objects (tables,

views, etc.).

10. Advanced SQL Features:

o Subqueries: Nested queries that can return data to another

query.

o Joins: Combine data from multiple tables.

o Aggregation: Functions like COUNT, AVG, MIN, MAX, etc.

o Transactions: Handling multiple SQL operations as a unit.

3
11. Embedded SQL & Dynamic SQL:

o Embedded SQL: SQL statements within a host programming

language.

o Dynamic SQL: SQL commands that are constructed at

runtime, often used for complex queries.

UNIT II: Database Design

1. Entity-Relationship (E-R) Model:

o A high-level conceptual data model that visually represents

entities and their relationships.

o Entities: Real-world objects or concepts (e.g., Student,

Employee).

o Relationships: Associations between entities (e.g., Enrolled,

Works).

2. E-R Diagrams:

o Diagrammatic representation of the E-R model using

symbols like rectangles (entities), diamonds (relationships),

and ovals (attributes).

3. Enhanced-ER Model:

o Adds features like generalization, specialization, and

aggregation to the basic E-R model for more complex data

relationships.

4
4. ER-to-Relational Mapping:

o Translating an E-R diagram into a relational schema (tables)

by converting entities, attributes, and relationships into

tables and keys.

5. Functional Dependencies:

o A relationship between attributes in a table where one

attribute (or set of attributes) determines another.

6. Normalization:

o Organizing data to reduce redundancy and improve

integrity.

 1NF: Eliminate repeating groups.

 2NF: Eliminate partial dependencies.

 3NF: Eliminate transitive dependencies.

 BCNF: A stricter version of 3NF.

 4NF: Deal with multi-valued dependencies.

 5NF: Handle join dependencies.

7. Non-loss Decomposition:

o Decomposing a relation into smaller relations without losing

any information (i.e., join of decomposed relations should

give the original relation).

8. Dependency Preservation:

o Ensuring that functional dependencies are preserved when

decomposing a relation.

5
UNIT III: Transactions

1. Transaction Concepts:

o A transaction is a sequence of operations that must be

treated as a single unit (either fully completed or not

executed at all).

2. ACID Properties:

o Atomicity: A transaction is all or nothing.

o Consistency: A transaction takes the database from one

consistent state to another.

o Isolation: Transactions do not interfere with each other.

o Durability: Changes made by a transaction are permanent.

3. Schedules & Serializability:

o A schedule is a sequence of transactions. A schedule is

serializable if the results of concurrent transactions are the

same as if they had been executed sequentially.

4. Concurrency Control:

o Techniques to ensure that transactions execute in a way that

maintains database consistency, including:

 Locking: Prevent conflicting transactions from accessing

the same data.

 Timestamping: Ensures transaction order based on

timestamps.

 Multiversion: Keeps multiple versions of data for

consistency.
6
5. Deadlock Handling:

o Mechanisms to prevent or resolve deadlocks, where

transactions wait indefinitely for resources locked by each

other.

6. Recovery Concepts:

o Techniques to recover the database to a consistent state after

a failure.

 Deferred update: Only writes to the database after a

transaction is complete.

 Immediate update: Writes changes immediately, with

recovery mechanisms in place.

 Shadow paging: Uses a copy of the database page for

recovery.

7. ARIES Algorithm:

o A recovery algorithm that uses logs to ensure atomicity and

durability in transaction management.

UNIT IV: Implementation Techniques

1. RAID:

o Redundant Array of Independent Disks: Storage technology

that combines multiple disks for fault tolerance,

performance, and data redundancy.

7
2. File Organization:

o Techniques for efficiently storing and retrieving data, such

as sequential or direct access methods.

3. Indexing and Hashing:

o Indexing: Using indices (like B-trees) to speed up data

retrieval.

o Hashing: A technique for direct access to data using hash

functions.

4. Ordered Indices (B-tree, B+ tree):

o Balanced tree structures for indexing that maintain sorted

order for efficient searching.

5. Query Processing:

o The process of transforming a high-level query (e.g., SQL) into

an efficient execution plan.

o Query Optimization: Using heuristics to find the most

efficient query execution strategy.

6. Cost Estimation:

o Estimating the cost of various query execution plans to

choose the most efficient one.

8
UNIT V: Advanced Topics

1. Distributed Databases:

o Databases that are distributed across multiple locations or

systems, requiring methods for coordination and

management.

o Data Storage, Transaction Processing, Query Optimization:

Handling data consistency, availability, and partition

tolerance across systems.

2. NOSQL Databases:

o Document-based: Store data in documents (e.g., MongoDB).

o Key-value stores: Simple data storage in key-value pairs (e.g.,

Redis).

o Column-based: Store data in columns instead of rows (e.g.,

Cassandra).

o Graph databases: Store relationships between data using

graph structures (e.g., Neo4j).

3. CAP Theorem:

o States that in a distributed database, only two of the three

properties—Consistency, Availability, and Partition

tolerance—can be fully satisfied at the same time.

4. Database Security:

o Access control: Ensuring only authorized users can access

certain data.

9
o SQL Injection: Protecting against malicious input that

manipulates SQL queries.

o Encryption: Securing data using cryptographic techniques.

o Public Key Infrastructure (PKI): A system for managing

encryption keys and digital certificates.

UNIT I: Relational Databases

1. Purpose of Database Systems:

o Databases help in data management by allowing efficient

storage, retrieval, and modification of data. They also help

maintain data consistency, integrity, and security.

o Example: A bank uses a database to manage customer

accounts and transactions, ensuring data consistency and

preventing data duplication.

2. Views of Data:

o External View: This is how end users interact with the data.

It’s typically represented in a user-friendly way, like through

reports or dashboards. Different users might have different

views depending on their access level.

o Conceptual View: Describes the logical structure of the

database, independent of physical considerations. It’s the

"middle layer" of abstraction that defines the structure of

data and relationships.

10
o Internal View: Describes how the data is actually stored (e.g.,

in files or in memory). This level is not concerned with how

the data is used but focuses on how it is physically organized

for performance.

3. Relational Model:

o Relation: A table. A table consists of rows (tuples) and

columns (attributes).

o Example: A student table might have columns for student

ID, name, and date of birth, where each row represents an

individual student.

4. Relational Algebra:

o Used for manipulating relations (tables) and forming queries.

 SELECT: Selects a subset of rows based on a condition.

 PROJECT: Selects specific columns.

 JOIN: Combines rows from two or more tables based on

a related column.

 UNION: Combines rows from two tables, eliminating

duplicates.

 INTERSECTION: Returns rows that appear in both

tables.

5. SQL Fundamentals:

o SELECT: Retrieves data from a database.

sql

CopyEdit

11
SELECT * FROM students; -- Retrieves all columns and rows from the

students table

o INSERT, UPDATE, DELETE: Modifying data in tables.

sql

CopyEdit

INSERT INTO students (id, name) VALUES (1, 'John Doe');

UPDATE students SET name = 'Jane Doe' WHERE id = 1;

DELETE FROM students WHERE id = 1;

o CREATE TABLE: Creating a new table with specific columns

and types.

UNIT II: Database Design

1. Entity-Relationship (E-R) Model:

o This is a high-level conceptual model used to represent real-

world entities and relationships. It’s the blueprint for a

database.

 Entity: Something that exists and is distinguishable (e.g.,

Student, Course).

 Relationship: How entities are related to each other

(e.g., A Student "enrolls" in a Course).

2. Normalization:

o Normalization is the process of structuring a database in

such a way that redundancy is minimized.

12
 1NF: Eliminate duplicate columns and make sure each

column contains atomic values (no multiple values in a

single column).

 2NF: Eliminate partial dependency (a column should

depend on the entire primary key, not just part of it).

 3NF: Eliminate transitive dependency (non-key

attributes should depend only on the primary key).

 BCNF: A stricter form of 3NF where every determinant

is a candidate key.

3. Dependency Preservation:

o Ensures that the functional dependencies are preserved when

decomposing relations into smaller ones, which helps

maintain integrity.

UNIT III: Transactions

1. ACID Properties:

o Atomicity: A transaction is an indivisible unit. If one part of

the transaction fails, the entire transaction is rolled back.

o Consistency: After a transaction, the database must be in a

valid state, adhering to all integrity constraints.

o Isolation: Ensures that transactions are executed

independently, even if they run concurrently.

o Durability: Once a transaction is committed, its changes are

permanent, even in case of system crashes.

13
2. Concurrency Control:

o Multiple transactions can access the database

simultaneously. Concurrency control ensures that these

transactions don’t interfere with each other and lead to

inconsistencies.

 Locking: Prevents transactions from accessing the same

data simultaneously.

 Timestamp ordering: Transactions are assigned

timestamps, and the order of execution is determined by

these timestamps.

 Multiversion concurrency control: Maintains multiple

versions of data for reading while allowing updates to

happen in parallel.

3. Deadlock Handling:

o A deadlock occurs when two or more transactions are

waiting for each other to release resources, leading to a

standstill. There are several ways to handle it:

 Deadlock detection: The system periodically checks for

deadlocks and resolves them by aborting one of the

transactions.

 Deadlock prevention: The system uses strategies like the

wait-die or wound-wait schemes to prevent deadlocks

from occurring.

14
UNIT IV: Implementation Techniques

1. RAID:

o RAID (Redundant Array of Independent Disks) is a storage

technology that combines multiple disks to improve

performance and reliability.

 RAID 0: Data is split across multiple disks, improving

speed but no redundancy.

 RAID 1: Data is mirrored across two disks, providing

redundancy.

 RAID 5: Data is striped across multiple disks with

parity for fault tolerance.

2. Indexing and Hashing:

o Indexing: An index allows fast lookup of data based on

certain columns. B-trees and B+ trees are commonly used for

indexing.

o Hashing: A technique used to quickly locate data by

applying a hash function. Static hashing uses a fixed number

of buckets, while dynamic hashing adjusts as data grows.

3. Query Processing & Optimization:

o Query Processing: Involves parsing the query, planning the

execution, and executing it in the most efficient way.

o Query Optimization: Aiming to reduce the execution time,

often by choosing the most efficient algorithm for operations

like joins, sorting, etc.


15
 Heuristic-based optimization: Uses predefined rules to

reorder queries for efficiency.

UNIT V: Advanced Topics

1. Distributed Databases:

o Distributed databases are spread across multiple locations.

The main challenges are data consistency, synchronization,

and fault tolerance.

 Transaction Processing: Ensuring that transactions are

consistent across all databases, often using protocols like

Two-Phase Commit.

2. NOSQL Databases:

o Document-based (e.g., MongoDB): Data is stored in JSON-like

documents.

o Key-Value Stores (e.g., Redis): Stores data as key-value pairs

for fast access.

o Graph Databases (e.g., Neo4j): Data is stored as nodes

(entities) and edges (relationships).

3. Database Security:

o SQL Injection: A common attack where malicious SQL code is

inserted into input fields, potentially giving attackers

unauthorized access to the database.

 Prevention: Use prepared statements and

parameterized queries to avoid SQL injection.

16
4. Encryption & Public Key Infrastructure:

o Encryption ensures that data is unreadable to unauthorized

users, using algorithms like AES or RSA.

o Public Key Infrastructure (PKI) is a framework for

managing encryption keys and certificates, ensuring secure

data transmission.

UNIT I: Relational Databases

 Purpose of Database Systems:

Databases are designed to store and manage data efficiently.

Example: A library database stores information about books,

borrowers, and transactions, ensuring no duplication and fast

access.

 Views of Data:

o External View: What end-users see and interact with.

Example: A student interface showing all enrolled courses.

o Conceptual View: The logical design of data, abstracted from

physical storage.

Example: Representation of student, course, and enrollment

tables.

o Internal View: How data is physically stored (e.g., in files).

Example: Data might be stored on disk in blocks.

 Relational Model:

Data is stored in tables (relations), with rows (tuples) and columns

17
(attributes).

Example: A student table with columns for student_id, name, dob.

student_id name dob

1 John 2000-01-01

2 Alice 1999-03-14

Keys:

o Primary Key: Uniquely identifies each record.

Example: In the student table, student_id is the primary key.

o Foreign Key: Links one table to another.

Example: A course table with a student_id as a foreign key

linking to the student table.

 Relational Algebra:

o SELECT: Retrieves data based on a condition.

Example: SELECT * FROM students WHERE name='John';

o JOIN: Combines data from two tables based on a common

column.

Example: SELECT students.name, courses.name FROM students JOIN

courses ON students.student_id = courses.student_id;

 SQL Fundamentals:

o SELECT: Retrieves data.

Example: SELECT name FROM students WHERE student_id=1;

18
o INSERT: Adds new records.

Example: INSERT INTO students (student_id, name, dob) VALUES (3, 'Bob',

'2001-05-20');

o UPDATE: Modifies existing records.

Example: UPDATE students SET name='John Doe' WHERE student_id=1;

o DELETE: Removes records.

Example: DELETE FROM students WHERE student_id=3;

UNIT II: Database Design

 Entity-Relationship (E-R) Model:

Models real-world entities and relationships.

Example: An E-R diagram with Student and Course entities, where

Student enrolls in Course.

 E-R Diagrams:

Visual representation of entities, attributes, and relationships.

Example: A diagram showing Student (ID, Name) and Course (ID,

Name) with a relationship "enrolled in."

 Normalization:

Organizing data to reduce redundancy.

o 1NF: Eliminate repeating groups (ensure all attributes are

atomic).

Example: Course(1001, Math, 10A, John) → Separate into two rows

if multiple students enroll in the same course.

19
o 2NF: Remove partial dependencies (non-key attributes

depend on the whole primary key).

o 3NF: Remove transitive dependencies (non-key attributes

depend only on the primary key).

 ER-to-Relational Mapping:

Convert E-R diagrams into relational schema.

Example: The Student entity becomes a table with student_id, name,

and dob attributes.

UNIT III: Transactions

 Transaction Concepts:

A transaction is a unit of work that must be either fully

completed or fully rolled back.

Example: In a bank, transferring money from one account to

another must either succeed completely or not happen at all.

 ACID Properties:

o Atomicity: The transaction is atomic; it either completes

entirely or doesn’t happen at all.

Example: A bank transfer must either deduct from one

account and add to another, or nothing happens.

o Consistency: Ensures the database transitions from one valid

state to another.

Example: A balance check ensures no negative balances.

20
o Isolation: Transactions should not interfere with each other.

Example: If two transactions try to update the same account,

isolation ensures no conflicts occur.

o Durability: Once a transaction is committed, it cannot be

undone.

Example: If a bank transfer is completed, the new balance is

permanently saved.

 Concurrency Control:

Manages simultaneous transactions.

Example: Locking: Transaction A locks a record until it’s done,

preventing Transaction B from modifying it at the same time.

 Deadlock Handling:

Preventing or resolving situations where transactions are stuck

waiting on each other.

Example: Transaction A holds a lock on Account X, and

Transaction B holds a lock on Account Y. They both wait for each

other to release the lock.

UNIT IV: Implementation Techniques

 RAID (Redundant Array of Independent Disks):

Combines multiple disks for redundancy or performance

improvement.

Example: RAID 1 mirrors data across two disks, providing fault

tolerance.

21
 Indexing & Hashing:

o Indexing: Improves query performance by providing fast

access to rows in a table.

Example: A B-tree index allows fast lookups by student_id in

the student table.

o Hashing: A technique for directly accessing data via a hash

function.

Example: Hashing a student_id value to find the student’s

record quickly.

 Query Processing:

The process of turning a SQL query into an execution plan.

Example: For SELECT * FROM students WHERE name='John' , the system

decides the best way to retrieve the data, perhaps using an index

on name.

UNIT V: Advanced Topics

 Distributed Databases:

Data is stored across multiple machines.

Example: A company’s database is distributed across different

geographical locations to improve access speed and fault

tolerance.

 NOSQL Databases:

Non-relational databases for specific workloads.

22
o Document-based (e.g., MongoDB): Stores data in JSON-like

documents.

Example: A student document might look like { "student_id": 1,

"name": "John", "courses": ["Math", "Science"] }.

o Key-Value Stores (e.g., Redis): Stores data as key-value pairs.

Example: student:1 → { "name": "John", "age": 21 }.

o Graph Databases (e.g., Neo4j): Stores data in nodes and

relationships.

Example: A student node might be related to course nodes by

"enrolled in."

 Database Security:

o SQL Injection: A form of attack where malicious SQL code is

inserted into an input field to exploit vulnerabilities.

Example: SELECT * FROM users WHERE username='admin' AND

password='' OR 1=1; --.

o Encryption: Protects sensitive data.

Example: AES encryption might be used to store passwords

securely.

23
UNIT I: Relational Databases

2-Mark Questions:

 Remember:
1. What is a relational database?

2. Define Primary Key.

3. What is SQL Injection?

4. What is Relational Algebra?

 Understand:
1. Explain the purpose of Database System.

2. What is meant by Foreign Key?

3. Explain the difference between Embedded SQL and Dynamic SQL.

 Apply:
1. Provide an example of a JOIN operation in SQL.

2. What is the role of indexes in a database? Give an example.

 Analyze:
1. Analyze the differences between Relational Model and Hierarchical

Model.

2. Explain the significance of ACID properties in a DBMS.

 Evaluate:
1. Evaluate the importance of Relational Algebra in database querying.

2. Discuss the pros and cons of Dynamic SQL over Embedded SQL.

 Create:
1. Create a simple SQL query to fetch records from a database table based

on certain conditions.

2. Design a simple E-R diagram for a Library Management System.

24
16-Mark Questions:

 Remember:
1. Define and explain the terms Primary Key, Foreign Key, and

Relational Algebra.

 Understand:
1. Explain the Relational Model with suitable examples.

2. Discuss the working of SQL SELECT, INSERT, and UPDATE statements

with examples.

 Apply:
1. Demonstrate how Normalization works through examples of 1NF,

2NF, and 3NF.

2. Provide examples to demonstrate Subqueries in SQL and explain how

they help in querying.

 Analyze:
1. Analyze the differences between Embedded SQL and Dynamic SQL with

examples.

2. Evaluate the use of SQL Joins and explain which join would be ideal for

different data retrieval requirements.

 Evaluate:
1. Evaluate the impact of SQL Injection on a database system and suggest

measures to prevent it.

2. Critically evaluate the concept of Indexes and how they improve query

performance.

 Create:
1. Create a database schema for a Student Enrollment System using

relational tables and explain its structure.

2. Design a database query optimization plan using heuristics.


25
UNIT II: Database Design

2-Mark Questions:

 Remember:
1. Define Entity-Relationship (E-R) Model.

2. What is the Functional Dependency?

3. State the difference between 1NF and 2NF.

 Understand:
1. Explain Normalization.

2. Describe the importance of BCNF in database design.

 Apply:
1. Apply Functional Dependency to decompose a table into 2NF.

2. Provide an example of E-R Diagram for an online shopping system.

 Analyze:
1. Analyze the difference between 2NF and 3NF normalization.

2. Explain how ER-to-Relational Mapping is done with an example.

 Evaluate:
1. Evaluate the significance of BCNF in database design.

2. Discuss the importance of Non-loss Decomposition.

 Create:
1. Create an E-R diagram for a Library Management System.

2. Design a schema for Student Registration based on 3NF principles.

16-Mark Questions:

 Remember:
1. Define Normalization and describe its types (1NF, 2NF, 3NF, BCNF).

2. Describe the process of ER-to-Relational Mapping.


26
 Understand:
1. Explain the significance of Functional Dependencies in normalization.

2. Describe E-R Diagrams and how they help in designing databases.

 Apply:
1. Apply the process of Normalization to convert an unnormalized

schema into 3NF.

2. Create a Normalization procedure to decompose a given relation into

BCNF.

 Analyze:
1. Analyze the issues with the schema if it's not in BCNF and suggest

improvements.

2. Compare and contrast 1NF, 2NF, and 3NF with examples.

 Evaluate:
1. Evaluate the effectiveness of Non-loss Decomposition in maintaining

data integrity.

2. Discuss the trade-offs between 2NF and 3NF.

 Create:
1. Design a Library Management System using E-R diagrams and

implement it with relational tables.

2. Create a Normalization process for an online e-commerce system to

achieve BCNF.

UNIT III: Transactions

2-Mark Questions:

 Remember:
1. What is a transaction in DBMS?

27
2. What does ACID stand for in transactions?

 Understand:
1. Explain Concurrency Control.

2. Define Deadlock in transactions.

 Apply:
1. How do you use Two-Phase Locking in DBMS to control concurrency?

2. Provide an example of Serializability in transactions.

 Analyze:
1. Analyze the role of ACID properties in ensuring transaction integrity.

2. Evaluate the differences between Deferred Update and Immediate

Update recovery.

 Evaluate:
1. Evaluate the impact of Deadlock Handling on transaction

performance.

2. Discuss how Timestamp Ordering ensures serializability.

 Create:
1. Design a transaction management system for an e-commerce platform.

2. Create a deadlock prevention mechanism for concurrent transactions.

16-Mark Questions:

 Remember:
1. Define and explain the ACID properties of transactions.

 Understand:
1. Explain Two-Phase Locking Protocol with examples.

2. Discuss Concurrency Control techniques used in DBMS.

28
 Apply:
1. Apply the ACID properties to a banking transaction and describe how

each property ensures data integrity.

2. Demonstrate how Timestamp Ordering works for ensuring consistency

across concurrent transactions.

 Analyze:
1. Analyze how Two-Phase Locking prevents deadlock in DBMS.

2. Evaluate the effectiveness of Deferred Update and Immediate Update

recovery techniques.

 Evaluate:
1. Critically evaluate the role of deadlock handling in DBMS and suggest

methods for preventing deadlocks.

2. Evaluate the performance trade-offs between timestamp ordering and

two-phase locking in transaction management.

 Create:
1. Design a recovery strategy for a financial transaction system based on

the ARIES algorithm.

2. Create a system to handle concurrent transactions for a multi-user

online game using Two-Phase Locking.

UNIT IV: Implementation Techniques

2-Mark Questions:

 Remember:
1. Define RAID in the context of DBMS.

2. What is B+ Tree indexing?

29
 Understand:
1. Explain File Organization in DBMS.

2. What is the difference between Ordered Indices and Hash Indices?

 Apply:
1. Apply B+ Tree indexing to speed up search queries.

2. Give an example of Dynamic Hashing in action.

 Analyze:
1. Analyze the difference between Static Hashing and Dynamic Hashing.

2. Compare Column-Oriented Storage with Row-Oriented Storage.

 Evaluate:
1. Evaluate the advantages of RAID in improving disk performance and

fault tolerance.

2. Discuss the impact of Query Optimization on query execution time.

 Create:
1. Design a hashing algorithm for efficiently storing employee records in

a database.

2. Create a query optimization plan for a database involving multiple

complex joins.

16-Mark Questions:

 Remember:
1. Define RAID and describe its levels.

2. Explain File Organization methods in DBMS.

 Understand:
1. Describe B+ Tree indexing and explain how it improves query

performance.

30
2. Explain Query Processing and how it translates SQL into execution

plans.

 Apply:
1. Apply Dynamic Hashing and explain its advantages over static

hashing.

2. Create a file organization strategy for a large-scale e-commerce

platform.

 Analyze:
1. Analyze the impact of RAID levels on data availability and

performance.

2. Compare B-trees and B+ trees in terms of performance and use cases.

 Evaluate:
1. Evaluate the performance of different Query Optimization techniques

(Heuristics, Cost-based).

2. Discuss the advantages and limitations of Column-Oriented Storage.

 Create:
1. Design a file organization strategy for a video streaming platform’s

database.

2. Create a B+ Tree index for an employee table that speeds up salary

queries.

UNIT V: Advanced Topics

2-Mark Questions:

 Remember:
1. What is NOSQL?

2. What is CAP Theorem?

31
 Understand:
1. Explain the concept of Graph Databases.

2. Define Encryption in the context of database security.

 Apply:
1. Apply the CAP Theorem to a distributed database scenario.

2. Give an example of SQL Injection and suggest a preventive measure.

 Analyze:
1. Analyze the differences between Document-based and Key-Value

NOSQL databases.

2. Discuss the importance of Database Security and explain how

encryption protects sensitive data.

 Evaluate:
1. Evaluate the strengths and weaknesses of NOSQL databases compared

to traditional relational databases.

2. Discuss how Role-Based Access Control (RBAC) can help secure a

database.

 Create:
1. Design a NOSQL schema for a blog website that uses Document-based

storage.

2. Create a Database Encryption strategy for storing personal data

securely.

32
UNIT I: Relational Databases

2-Mark Questions and Answers:

 Remember:

1. What is a relational database?

Answer: A relational database is a type of database that

stores data in tables (relations), where each table consists of

rows (tuples) and columns (attributes). It uses keys to define

relationships between tables.

2. Define Primary Key.

Answer: A primary key is a unique identifier for a record in

a database table. No two records can have the same primary

key value.

 Understand:

1. Explain the purpose of a Database System.

Answer: The purpose of a database system is to efficiently

store, manage, and retrieve data while ensuring data

consistency, integrity, and security. It also provides a

systematic method for managing large amounts of data and

allows for easier data access.

2. What is meant by a Foreign Key?

Answer: A foreign key is an attribute in a table that creates

a relationship between that table and another. It points to

33
the primary key in another table, establishing a link between

the two.

 Apply:

1. Provide an example of a JOIN operation in SQL.

Answer:

sql

CopyEdit

SELECT students.name, courses.course_name

FROM students

INNER JOIN enrollments ON students.student_id = enrollments.student_id

INNER JOIN courses ON enrollments.course_id = courses.course_id;

2. What is the role of indexes in a database? Give an example.

Answer: Indexes improve the speed of data retrieval

operations on a database. For example, a database may have

an index on the student_id column in a students table to speed up

queries searching for specific students.

 Analyze:

1. Analyze the differences between the Relational Model and

the Hierarchical Model.

Answer: In the Relational Model, data is organized in tables,

and relationships are established using keys. The

Hierarchical Model organizes data in a tree-like structure,

where each record has a single parent. The Relational Model

is more flexible and supports complex relationships, while the

34
Hierarchical Model is less flexible and supports one-to-many

relationships only.

2. Explain the significance of ACID properties in a DBMS.

Answer: ACID properties (Atomicity, Consistency, Isolation,

Durability) ensure reliable transaction processing in a

database. Atomicity ensures that all operations in a

transaction are completed; Consistency ensures that the

database transitions from one valid state to another;

Isolation ensures transactions do not interfere with each

other; Durability ensures that committed transactions

persist even after a crash.

 Evaluate:

1. Evaluate the importance of Relational Algebra in database

querying.

Answer: Relational Algebra is crucial as it provides the

theoretical foundation for querying relational databases. It

defines operations like select, project, and join that enable

efficient retrieval and manipulation of data in a relational

system.

2. Discuss the pros and cons of Dynamic SQL over Embedded

SQL.

Answer: Pros: Dynamic SQL allows for more flexibility in

creating queries at runtime, making it adaptable to

changing user inputs.

35
Cons: It can be slower due to the need for runtime parsing

and execution. Embedded SQL is more efficient as it is pre-

compiled and tightly integrated with application code, but it

lacks flexibility.

 Create:

1. Create a simple SQL query to fetch records from a database

table based on certain conditions.

Answer:

sql

CopyEdit

SELECT * FROM employees

WHERE department = 'Sales' AND salary > 50000;

2. Design a simple E-R diagram for a Library Management

System.

Answer:
 Entities: Book, Member, Loan

 Relationships:

 Member borrows Book (Many-to-Many)

 Attributes:

 Book: book_id, title, author

 Member: member_id, name, address

 Loan: loan_id, borrow_date, return_date

36
16-Mark Questions and Answers:

 Remember:
1. Define and explain the terms Primary Key, Foreign Key, and

Relational Algebra.

Answer:

 Primary Key: A unique identifier for a record in a table.

 Foreign Key: A field in one table that is a primary key in

another table, used to establish relationships.

 Relational Algebra: A formal system for manipulating relations

(tables), including operations like selection, projection, and join.

 Understand:

1. Explain the Relational Model with suitable examples.

Answer:

The Relational Model organizes data in tables with rows and

columns. Each row represents a record, and each column

represents an attribute. Example:

Table Students:

student_id name age

1 John 20

2 Alice 22

A relationship can be established by a foreign key, like

course_id in a Student_Courses table.

37
2. Discuss the working of SQL SELECT, INSERT, and UPDATE

statements with examples.

Answer:
 SELECT: Retrieves data from a table.

sql

CopyEdit

SELECT name FROM students WHERE age > 20;

 INSERT: Adds new records to a table.

sql

CopyEdit

INSERT INTO students (student_id, name, age) VALUES (3, 'Bob', 21);

 UPDATE: Modifies existing records in a table.

sql

CopyEdit

UPDATE students SET age = 23 WHERE student_id = 2;

 Apply:

1. Demonstrate how Normalization works through examples of

1NF, 2NF, and 3NF.

Answer:
 1NF: Ensures all attributes contain atomic values.

Example: A table with student_id, subjects (list of subjects), is

converted to atomic values by breaking the list into separate

rows.
38
 2NF: Achieved when 1NF is satisfied, and all non-key attributes

are fully dependent on the primary key.

 3NF: Achieved when 2NF is satisfied, and all non-key attributes

are independent of each other.

2. Provide examples to demonstrate Subqueries in SQL and

explain how they help in querying.

Answer:

Example of a Subquery:

sql

CopyEdit

SELECT name FROM students WHERE student_id IN (SELECT student_id

FROM enrollments WHERE course_id = 101);

A subquery allows you to nest one query inside another,

enabling more complex searches.

 Analyze:

1. Analyze the differences between Embedded SQL and

Dynamic SQL with examples.

Answer:
 Embedded SQL: SQL queries are embedded within programming

languages like C, Java, and compiled before execution. Example:

CopyEdit

EXEC SQL SELECT * FROM students;

39
 Dynamic SQL: SQL queries are created at runtime based on user

inputs. Example:

sql

CopyEdit

EXECUTE IMMEDIATE 'SELECT * FROM ' || table_name;

2. Evaluate the use of SQL Joins and explain which join would

be ideal for different data retrieval requirements.

Answer:
 INNER JOIN: Returns only matching rows from both tables.

 LEFT JOIN: Returns all rows from the left table and matching

rows from the right table.

 RIGHT JOIN: Returns all rows from the right table and matching

rows from the left table.

Evaluation: Use INNER JOIN when you only need rows with

matching data; use LEFT JOIN when you need all rows from the

left table even if there’s no match.

UNIT II: Database Design

2-Mark Questions and Answers:

 Remember:

1. What is an Entity-Relationship (E-R) model?

Answer: The Entity-Relationship (E-R) model is a conceptual

framework used to design databases. It uses entities (objects)

and relationships between them to represent the structure of

data.
40
2. What are Functional Dependencies?

Answer: Functional dependencies describe the relationship

between attributes in a relational database. An attribute Y

is functionally dependent on attribute X if for each value of

X, there is exactly one value of Y.

 Understand:

1. Explain the concept of the First Normal Form (1NF).

Answer: A table is in First Normal Form (1NF) if it contains

only atomic (indivisible) values and each column contains

unique values for each row.

2. What is Boyce-Codd Normal Form (BCNF)?

Answer: Boyce-Codd Normal Form (BCNF) is a stricter

version of 3NF, where every determinant is a candidate key.

In BCNF, there should be no exceptions to functional

dependencies.

 Apply:

1. How would you convert an E-R diagram to a relational

schema?

Answer: Convert entities to tables, relationships to foreign

keys, and attributes to columns. For example, an entity

Student would become a table with columns student_id, name, age.

A relationship like Enrollment would be translated into a table

with foreign keys referencing Student and Course.

41
2. Explain how to normalize a database to the Third Normal

Form (3NF).

Answer:
1. Start with the database in 1NF.

2. Move to 2NF by ensuring that all non-key attributes depend on

the entire primary key (eliminate partial dependencies).

3. Convert to 3NF by removing transitive dependencies (attributes

that depend on non-key attributes).

 Analyze:

1. Compare 2NF and 3NF.

Answer:
 2NF: A table is in 2NF if it is in 1NF and has no partial

dependency (non-prime attributes must depend on the whole

primary key).

 3NF: A table is in 3NF if it is in 2NF and has no transitive

dependencies (non-prime attributes depend only on candidate

keys).

What is the difference between functional dependency and

multivalued dependency?

Answer:
 Functional Dependency: A relationship where one attribute

determines another. For example, if student_id determines

student_name.

 Multivalued Dependency: Occurs when one attribute in a

relation determines a set of values for another attribute, such as

student_id determining multiple subjects in a student_courses

relation.
42
Evaluate:

Evaluate the importance of normalizing a database to BCNF.

Answer: Normalizing to BCNF ensures data integrity and reduces

redundancy. It also eliminates anomalies like insertion, deletion, and

update anomalies. However, strict adherence to BCNF can lead to a

complex schema with many tables, which may affect performance.

Discuss the implications of non-loss decomposition in database

normalization.

Answer: Non-loss decomposition ensures that after dividing a table

into smaller tables, the original table can be reconstructed without

losing any information. It’s essential to preserve data integrity and

prevent data anomalies during normalization.

Create:

Create an Entity-Relationship diagram for a Student-Course

Enrollment System.

Answer:
 Entities: Student, Course, Enrollment

 Attributes:

 Student: student_id, student_name, age

 Course: course_id, course_name, credits

 Enrollment: enrollment_id, enrollment_date

 Relationships:

 Student enrolls in Course (Many-to-Many), represented by

the Enrollment entity.

43
Design a relational schema for a Library system that maintains Books

and Members information.

Answer:

Tables:
 Books(book_id, title, author, year)

 Members(member_id, name, membership_date)

 Loans(loan_id, book_id, member_id, issue_date, return_date)

Relationships:

 A Book can be borrowed by many Members, so the Loans table

captures this many-to-many relationship.

UNIT III: Transactions

2-Mark Questions and Answers:

 Remember:

1. What is a transaction in a database?

Answer: A transaction is a sequence of one or more database

operations that are executed as a single unit of work. It must

be either fully completed or fully rolled back.

2. What are the ACID properties?

Answer: ACID stands for Atomicity, Consistency, Isolation,

and Durability, which ensure reliable transaction processing

in a database system.

 Understand:
44
1. Explain the concept of isolation in ACID properties.

Answer: Isolation ensures that the operations of a

transaction are isolated from other transactions. It prevents

data inconsistencies when multiple transactions are executed

concurrently.

2. What is deadlock in transactions?

Answer: Deadlock occurs when two or more transactions are

waiting for each other to release resources, causing a cyclic

dependency and preventing further progress.

 Apply:

1. How would you implement concurrency control in a

database system?

Answer: Concurrency control can be implemented using

techniques like two-phase locking, timestamps, or

multiversion concurrency control (MVCC) to ensure

transactions are executed without interference.

2. What is a recovery mechanism in transactions?

Answer: Recovery mechanisms restore the database to a

consistent state after a failure. Techniques include using

transaction logs, shadow paging, and checkpointing.

 Analyze:
45
1. Analyze the difference between deferred update and

immediate update in transaction recovery.

Answer:
 Deferred Update: Updates are not written to the database until a

transaction is committed. This reduces the chances of database

corruption in case of failure.

 Immediate Update: Updates are written to the database

immediately, which might lead to inconsistency if a failure occurs

before a transaction is committed.

2. Compare two-phase locking and timestamp-based

concurrency control.

Answer:
 Two-Phase Locking: Ensures that transactions lock data before

accessing it and unlock it after. It avoids conflicts but may lead to

deadlocks.

 Timestamp-based Concurrency: Assigns timestamps to

transactions and ensures that they execute in timestamp order,

providing a simpler method to avoid conflicts.

 Evaluate:

1. Evaluate the role of transaction logs in database recovery.

Answer: Transaction logs play a crucial role in database

recovery as they store details about the changes made by

each transaction. If a failure occurs, the database can use the

transaction log to redo or undo operations to restore

consistency.

46
2. Discuss the impact of deadlock handling on database

performance.

Answer: Deadlock handling mechanisms like wait-for graphs,

timeout, and deadlock detection increase database overhead,

but they ensure the system can recover from cyclic

dependencies. However, frequent deadlocks can degrade

system performance.

 Create:

1. Design a transaction management system that handles

concurrency and recovery.

Answer:
 Use two-phase locking for concurrency control.

 Implement logging for transaction tracking.

 Use checkpointing to periodically save the state of the database to

prevent excessive log rollbacks.

2. Create an example scenario of transaction isolation and

explain its working using SQL.

Answer:

Scenario: Two transactions trying to update the same record.

sql

CopyEdit

-- Transaction 1:

BEGIN TRANSACTION;

UPDATE accounts SET balance = balance - 100 WHERE account_id = 1;

-- Transaction 2 (while Transaction 1 is still active):


47
BEGIN TRANSACTION;

UPDATE accounts SET balance = balance + 100 WHERE account_id = 1;

COMMIT;

With Serializable Isolation, the second transaction will be

blocked until the first transaction is completed.

UNIT IV: Implementation Techniques

2-Mark Questions and Answers:

 Remember:

1. What is RAID in the context of database implementation?

Answer: RAID (Redundant Array of Independent Disks) is a

storage technology that combines multiple disk drives into a

single unit for data redundancy or performance

improvement.

2. What is a B+ Tree index?

Answer: A B+ Tree index is a balanced tree data structure

that maintains sorted data and allows efficient insertion,

deletion, and search operations. It is commonly used in

databases to speed up data retrieval.

 Understand:

1. Explain the purpose of indexing in databases.

Answer: Indexing speeds up data retrieval operations by

providing a fast search mechanism, allowing the database

48
engine to quickly locate data without scanning the entire

table.

2. What is static hashing in databases?

Answer: Static hashing is a technique used to map keys to

fixed locations in memory or storage, where the number of

buckets (locations) is fixed and does not change.

 Apply:

1. How does dynamic hashing differ from static hashing?

Answer: Dynamic hashing adjusts the number of buckets

based on the data volume, allowing for better handling of

growing datasets, while static hashing uses a fixed number of

buckets.

2. Explain how query optimization is used in databases.

Answer: Query optimization is the process of selecting the

most efficient execution plan for a SQL query. It involves

evaluating different query plans based on factors like cost,

index usage, and join methods.

 Analyze:

1. Compare B+ Tree and B Tree indexing techniques.

Answer:
 B Tree: A balanced tree where data can be stored in both internal

nodes and leaves.

 B+ Tree: A variation where data is stored only in leaf nodes and

internal nodes are used for indexing. B+ Trees provide faster

range queries as they maintain a linked list of leaf nodes.


49
2. Explain the significance of file organization in databases.

Answer: File organization determines how data is stored on

disk and impacts performance. Efficient file organization

can reduce disk I/O operations, speeding up query processing

and data retrieval.

 Evaluate:

1. Evaluate the effectiveness of Column-Oriented Storage over

Row-Oriented Storage in databases.

Answer: Column-oriented storage is more efficient for read-

heavy workloads, as it allows for quick access to specific

columns without loading entire rows. It’s commonly used in

analytical databases. Row-oriented storage is better for

transactional systems where complete records need to be

processed together.

2. Discuss the impact of query processing algorithms on

database performance.

Answer: Query processing algorithms, such as selection,

sorting, and join operations, directly affect the speed and

efficiency of queries. Optimized algorithms reduce resource

consumption and improve response time, enhancing overall

database performance.

50
 Create:

1. Design a simple indexing strategy for a database that stores

employee records with attributes like employee_id, name,

and department.

Answer:
 Create a B+ Tree index on employee_id for fast lookups.

 Optionally, create a hash index on department to quickly retrieve

employees belonging to specific departments.

2. Create a sample query processing algorithm for a database

join operation.

Answer:
 Hash Join Algorithm:

1. Partition the smaller table by hash function on the join key.

2. Scan the larger table and hash the join key.

3. Join records from both tables where hash values match.

UNIT V: Advanced Topics

2-Mark Questions and Answers:

 Remember:

1. What is the CAP theorem in distributed databases?

Answer: The CAP theorem states that a distributed database

system can only guarantee two out of three properties at the

same time: Consistency, Availability, and Partition

Tolerance.

51
2. What are Graph Databases?

Answer: Graph databases store data in nodes (entities) and

edges (relationships), making them suitable for handling

complex relationships between data points, such as social

networks.

 Understand:

1. Explain the difference between SQL and NoSQL databases.

Answer: SQL databases are relational and use structured

query language for managing data, whereas NoSQL

databases are non-relational and offer flexible schema

designs, ideal for unstructured or semi-structured data.

2. What is Role-Based Access Control (RBAC) in database

security?

Answer: RBAC is an access control model that restricts

system access to authorized users based on their roles,

ensuring users only have the necessary permissions to

perform their job functions.

 Apply:

1. How would you apply encryption for sensitive data in a

NoSQL database?

Answer:
 Use end-to-end encryption to encrypt data at rest and in transit.

 Implement field-level encryption for sensitive fields like credit

card numbers, ensuring only authorized users can decrypt them.

52
2. What is the significance of Data Storage in Distributed

Databases?

Answer: Data storage in distributed databases ensures data

redundancy and availability. It uses techniques like sharding

(partitioning data across multiple servers) and replication

(maintaining copies of data) to handle large volumes and

ensure fault tolerance.

 Analyze:

1. Compare Document-based NoSQL databases and Key-value

stores.

Answer:
 Document-based stores (like MongoDB) store data as documents

(JSON-like structures) and are ideal for hierarchical data.

 Key-value stores (like Redis) store data as key-value pairs,

offering high-speed access but lacking structure for complex

queries.

2. Analyze the challenges of database security in distributed

systems.

Answer: Challenges include ensuring data consistency across

nodes, protecting data from unauthorized access, and

managing encryption and authentication across multiple

locations. Distributed systems also have to handle network

partitioning and data integrity.

53
 Evaluate:

1. Evaluate the use of NoSQL databases in big data

applications.

Answer: NoSQL databases, such as Cassandra and MongoDB,

are highly scalable and can handle large volumes of

unstructured data. They are well-suited for big data

applications, but they may lack the strong consistency of

relational databases.

2. Discuss the impact of SQL Injection on database security and

how to mitigate it.

Answer: SQL Injection allows attackers to execute arbitrary

SQL commands, leading to data breaches, data loss, or system

compromise. Mitigation techniques include using prepared

statements, parameterized queries, and input validation.

 Create:

1. Design a NoSQL schema for an e-commerce website with

products, categories, and users.

Answer:
 Products: { product_id, name, price, description, category_id }

 Categories: { category_id, name, description }

 Users: { user_id, name, email, password_hash }

Relationships: A Product references a Category through

category_id, and a User can have multiple orders or reviews.

54
2. Create a database encryption strategy for sensitive personal

data (e.g., social security numbers).

Answer:
 Use AES-256 encryption for sensitive fields (e.g.,

social_security_number).

 Store encryption keys securely using hardware security modules

(HSMs) or key management services (KMS).

 Implement role-based access control to ensure only authorized

personnel can decrypt the data.

55

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy