content

Database Management Systems

Important Questions and Topics

Unit 1:

Q1. Database architecture

A DBMS (Database Management System) architecture refers to the overall design and organization of a DBMS, including the components, interfaces, and interactions between them. It provides a framework for managing and accessing data in a database.

Javatpoint

Q2. Database Schema and Models

Database schema:

GeeksForGeeks

Database schema Example

A Data Model in Database Management System (DBMS) is the concept of tools that are developed to summarize the description of the database. Data Models provide us with a transparent picture of data which helps us in creating an actual database. It shows us from the design of the data to its proper implementation of data.

GeeksForGeeks

Q3. Data Independence

Data independence is a property of a database management system by which we can change the database schema at one level of the database system without changing the database schema at the next higher level.

It has two types:

Logical Data Independence:

Physical Data Independence:

Summary:

GeeksForGeeks

Q4. Database Languages

Database languages are special-purpose languages that help with tasks like data definition, manipulation, and control:

Types of DB Languages

Naukri

Q5. Classification of DBMS

Types of DBMS

GeeksForGeeks

Unit 2:

Q1. Construct a ER diagram for Company database,Student database.

Q2. Define Entity, Relationship and types of cardinality

An Entity is a real-world object, person, place or thing that we are representing in the database.

A relationship in DBMS refers to the logical association between different entities that are stored in separate tables.

Types of Cardinality/Relationship:

ER Notations

BinaryTerms

Q4. What is an attribute? What are the types of attributes.

Already Answered in Q3

Q5. What is a relationship? Give an example of all types of relationships.

A Relationship in a Database refers to a connection between properties of tables.

The example for all the types of relationships are:

GeeksforGeeks

Unit 3:

Q1. What is a Domain, Attribute and Tuple?

Domain:

Attribute:

Tuple:

Gaurav Tiwari(Medium)

Q2. Explain Relational Model constraints: Domain Constraints, Referential Constraints,Integrity constraints, Null constraints.

Constraints are rules imposed on database contents to validate quality and ensure data integrity during operations like insertion and updates. They protect against threats and damages to the database.
The main types of constraints in a relational database are four.

Q3. Explain operators in Relational algebra? Specifically Unary, Projection, binary

Relational algebra is a procedural query language, which takes instances of relations as input and yields instances of relations as output. It uses operators to perform queries.

An operator can be either unary or binary. They accept relations as their input and yield relations as their output.

Types:

Q4. What is join operation? Explain its types with an example.

SQL JOIN clause is used to query and access data from multiple tables by establishing logical relationships between them.

I will explain the types with various examples. Consider two tables: employees and departments.

employees

id name dept_id
1 Alice 1
2 Bob 2
3 Charlie NULL
4 David 1

departments

id dept_name
1 HR
2 IT
3 Marketing
  1. Natural Join (⨝): This join automatically matches columns with the same name and data type in both tables. You don’t need to specify any condition. In this example, it would automatically join on the dept_id column, as it’s present in both tables.

Notation: R ⨝ S

Example:

SELECT employees.name, departments.dept_name FROM employees NATURAL JOIN departments;

Result:

id name dept_name
1 Alice HR
2 Bob IT
4 David HR
  1. Left Join (Left Outer Join) (⟕): This join returns all rows from the left table (employees), and the matching rows from the right table (departments). If there’s no match, NULL is returned for columns from the right table.

Notation: R ⟕ S

Example:

SELECT employees.name, departments.dept_name FROM employees LEFT JOIN departments ON employees.dept_id = departments.id;

Result:

name dept_name
Alice HR
Bob IT
Charlie NULL
David HR
  1. Right Join (Right Outer Join) (⟖): This join returns all rows from the right table (departments), and the matching rows from the left table (employees). If there’s no match, NULL is returned for columns from the left table.

Notation: R ⟖ S

Example:

SELECT employees.name, departments.dept_name FROM employees RIGHT JOIN departments ON employees.dept_id = departments.id;

Result:

name dept_name
Alice HR
Bob IT
NULL Marketing
  1. Full Join (Full Outer Join) (⟗): This join returns all rows when there is a match in either the left or right table. If there’s no match, NULL is returned for the unmatched rows.

Notation: R ⟗ S

MySQL does not directly support full outer join, but you can achieve it using a combination of left join and right join with a UNION.

Example:

SELECT employees.name, departments.dept_name FROM employees LEFT JOIN departments ON employees.dept_id = departments.id 
UNION 
SELECT employees.name, departments.dept_name FROM employees RIGHT JOIN departments ON employees.dept_id = departments.id;

Result:

name dept_name
Alice HR
Bob IT
Charlie NULL
David HR
NULL Marketing
  1. Inner Join: This join returns rows that have matching values in both tables.

Example:

SELECT employees.name, departments.dept_name FROM employees INNER JOIN departments ON employees.dept_id = departments.id;

Result:

name dept_name
Alice HR
Bob IT
David HR

Q5. Explain nested Queries with example

Nested queries are a way to perform complex queries by embedding one query within another. The outer query can apply some conditions on the results of the inner query. Let us use Students, Grades tables for understanding nested queries.

Input: Students table | StudentID | StudentName | Age | Major | |———–|————-|—–|—————| | 1 | Alice | 20 | Mathematics | | 2 | Bob | 21 | Computer Sci | | 3 | Charlie | 22 | Mathematics | | 4 | David | 19 | Physics |

Grades table: | StudentID | Subject | Score | |———–|————–|——-| | 1 | Mathematics | 95 | | 1 | Physics | 88 | | 2 | Computer Sci | 85 | | 3 | Mathematics | 92 | | 4 | Physics | 78 |

SELECT StudentName
FROM Students
WHERE StudentID IN (
    SELECT StudentID
    FROM Grades
    WHERE Subject = ‘Mathematics’ AND Score > 90
);

Output: | StudentName | |————-| | Alice | | Charlie |

GeeksForGeeks

Q6. Describe the PL/SQL block

PL/SQL Queries are more or less blocks of code.

Syntax:

DECLARE
    declaration statements;

BEGIN
    executable statements;

EXCEPTIONS
    exception handling statements;

END;

(GeeksForGeeks)

Q7. Features of PL/SQL

Features of PL/SQL:

GeeksForGeeks

Q8. What is cursor and its types

The cursor is used to retrieve data one row at a time from the results set, unlike other SQL commands that operate on all rows at once.

Cursors are classified depending on how they are opened:

Q9. Explain exception with an example?

An exception is an error which disrupts the normal flow of program instructions. PL/SQL provides us the exception block which raises the exception thus helping the programmer to find out the fault and resolve it.

There are two types of exceptions defined in PL/SQL:

GeeksForGeeks TODO: Finish

Unit 4:

Q1. Anomalies in relational Database design

Anomalies in the relational model refer to inconsistencies or errors that can arise when working with relational databases, specifically in the context of data insertion, deletion, and modification.

These anomalies can be categorized into three types:

GeeksForGeeks

Q2. Decomposition

When we divide a table into multiple tables or divide a relation into multiple relations, then this process is called Decomposition.

There are two types of Decomposition:

Decomposition in DBMS

GeeksForGeeks

Q3. Functional Dependencies

In relational database management, functional dependency is a concept that specifies the relationship between two sets of attributes where one attribute determines the value of another attribute.

There are Two Types of Functional Dependencies:

GeeksForGeeks

Q4. 1st normal Form, 2nd normal Form, 3rd normal form, BCNF

Normalization is the process of minimizing redundancy from a relation or set of relations.

Levels of Normalization:

Explanation:

(GeeksForGeeks, Explanation) (GeeksForGeeks, Forms)

Unit 5:

Q1. Transaction states

Transaction in DBMS is a set of logically related operations executed as a single unit.

Transaction States

GeeksForGeeks

Q2. Transaction operations

A user can make different types of requests to access and modify the contents of a database.

So, we have different types of operations relating to a transaction. They are discussed as follows:

GeeksForGeeks

Q3. Properties of Transaction

A transaction is a single logical unit of work that accesses and possibly modifies the contents of a database.

The acronym ACID stands for Atomicity, Consistency, Isolation, and Durability. ACID Can be broken down to:

ACID Properties

(GeeksForGeeks)

Q4. Concurrency control problem

Concurrency control is an essential aspect of database management systems that ensures transactions can execute concurrently without interfering with each other.

These problems are:

TODO: Finish

Q5. concurrency control techniques

Following are the Concurrency Control techniques in DBMS:

GeeksForGeeks

GeeksForGeeks(Lock Based Protocol)