0% found this document useful (0 votes)
8 views

Dbms Question Bank

Uploaded by

jatinpatidar702
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)
8 views

Dbms Question Bank

Uploaded by

jatinpatidar702
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/ 34

Unit 1

### Short Questions:

1. **Define: Data, Database, DBMS, Data Redundancy**

- **Data**: Raw facts and figures without context, such as numbers, text, or images.

- **Database**: A structured collection of data stored electronically, organized for easy


access, management, and updating.

- **DBMS (Database Management System)**: Software that manages and controls


access to the database, allowing users to store, retrieve, and manipulate data.

- **Data Redundancy**: The unnecessary duplication of data within a database or across


multiple databases.

2. **What is data and information?**

- **Data**: Raw, unprocessed facts or figures that are collected.

- **Information**: Processed or organized data that is meaningful and useful for decision-
making.

3. **Give the difference between data and information.**

- **Data** is raw and unprocessed, such as a list of numbers or names. **Information**


is data that has been processed or organized in a way that is meaningful and useful, such
as a report summarizing sales figures.

4. **Why do we need DBMS?**

- **DBMS** is needed to efficiently manage large volumes of data, ensure data integrity,
provide secure access, support concurrent data operations, and reduce data redundancy.

5. **Give the application of DBMS.**


- **Applications** of DBMS include managing customer records in CRM systems,
handling financial transactions in banking systems, and organizing inventory in retail
management systems.

6. **Explain the advantages and disadvantages of DBMS.**

- **Advantages**: Improved data sharing, data security, data integrity, reduced data
redundancy, and better data management.

- **Disadvantages**: Complexity, cost of DBMS software and hardware, potential


performance issues, and the need for skilled personnel.

7. **What is schema and instance? Explain with example.**

- **Schema**: The structure of the database, including tables, fields, relationships, and
constraints. For example, a university database schema might include tables for students,
courses, and enrollments.

- **Instance**: The actual data in the database at a given point in time. For example, a
student named John Doe enrolled in a course is an instance of the data in the students and
enrollments tables.

### Long Questions:

1. **Give the difference between FPS and DBMS.**

- **FPS (File Processing System)**: Uses file-based storage without a systematic


approach to manage data. Each application has its own files.

- **DBMS**: Uses a systematic approach to manage data, providing centralized control


and support for multiple applications to access and manipulate data through a single
interface.

2. **Why is DBMS better than FPS?**


- **DBMS** offers better data management, integrity, security, and reduced redundancy
compared to FPS. It supports concurrent access, provides tools for backup and recovery,
and facilitates complex queries.

3. **Explain in detail the three-layer architecture or ANSI/SPARC model of DBMS.**

- **Three-layer architecture**:

- **External Level**: User views of the database, tailored to different user requirements.

- **Conceptual Level**: The logical view of the entire database, defining the structure
and relationships between data.

- **Internal Level**: The physical storage of data, including indexing and data access
methods.

4. **What is Client-Server Architecture/Database Architecture? Explain 1-tier, 2-tier, 3-tier


architecture with diagrams.**

- **1-Tier Architecture**: The database and application are on the same system. Example:
A standalone database application on a desktop.

- **2-Tier Architecture**: The client (application) communicates directly with the server
(database). Example: A desktop application connecting to a remote database server.

- **3-Tier Architecture**: Includes a middle layer (application server) between the client
and the database. Example: A web application where the web server interacts with the
database server on behalf of the client.

```

1-Tier:

[Application + Database]

2-Tier:

[Client] <--> [Database Server]


3-Tier:

[Client] <--> [Application Server] <--> [Database Server]

```

5. **Explain the types of users of DBA.**

- **Database Administrator (DBA)**: Manages the database environment, including


configuration, performance tuning, security, and backup.

- **End Users**: Regular users who interact with the database through applications, such
as business analysts or customers.

- **Developers**: Create and maintain applications that interact with the database,
including designing and querying databases.

6. **What is data independence? Explain the difference between physical and logical data
independence with examples.**

- **Data Independence**: The ability to change the database schema at one level without
affecting the schema at other levels.

- **Physical Data Independence**: Changes to the physical storage of data (e.g.,


changing storage devices) do not affect the conceptual schema. For example, moving data
from one disk to another does not change how data is structured or accessed.

- **Logical Data Independence**: Changes to the conceptual schema (e.g., adding or


removing fields in a table) do not affect the external schema (user views). For example,
adding a new field to a table should not require changes to the application programs that
use that table.

These explanations cover fundamental concepts and differences relevant to database


systems and their architectures.
Unit 2
### Short Questions:

1. **Significance of Logical Operators (AND/OR) in SQL Predicates:**


Logical operators like `AND` and `OR` are used in SQL to combine multiple
conditions in a `WHERE` clause. They allow for more precise data retrieval by
specifying multiple criteria that must be met. For example:

```sql
SELECT * FROM Employees
WHERE (Department = 'Sales' AND Salary > 50000)
OR (Department = 'Marketing' AND Salary > 60000);
```
This query retrieves employees who are either in the 'Sales' department with a
salary above 50,000 or in the 'Marketing' department with a salary above 60,000.

2. **Use of the BETWEEN Predicate in SQL:**


The `BETWEEN` predicate is used to filter records within a specific range of
values. It is inclusive, meaning it includes the boundary values. For example:

```sql
SELECT * FROM Products
WHERE Price BETWEEN 10 AND 50;
```
This query retrieves products with a price ranging from 10 to 50.
3. **Aggregate Functions in SQL:**
Aggregate functions perform a calculation on a set of values and return a single
value. Common aggregate functions include:

- `COUNT()`: Counts the number of rows.


- `SUM()`: Calculates the sum of a numeric column.
- `AVG()`: Computes the average value of a numeric column.
- `MIN()`: Finds the minimum value.
- `MAX()`: Finds the maximum value.

Example:

```sql
SELECT Department, AVG(Salary) AS AverageSalary
FROM Employees
GROUP BY Department;
```
This query calculates the average salary for each department.

4. **Character Functions in SQL:**


Character functions are used to manipulate and query string values. Some
common character functions include:

- `CONCAT()`: Concatenates two or more strings.


- `SUBSTRING()`: Extracts a substring from a string.
- `LENGTH()`: Returns the length of a string.
- `UPPER()` and `LOWER()`: Converts a string to uppercase or lowercase.
- `TRIM()`: Removes leading and trailing spaces from a string.

Example:

```sql
SELECT CONCAT(FirstName, ' ', LastName) AS FullName
FROM Employees;
```
This query concatenates the first and last names of employees into a single full
name.

### Long Questions:

5. **What is SQL? Discuss the Different Languages of SQL and Its Commands:**
SQL (Structured Query Language) is a standard language for managing and
manipulating relational databases. It allows users to create, read, update, and delete
data within a database. SQL is divided into several sub-languages:

- **DDL (Data Definition Language):** Defines and manages database


structures. Commands include:
- `CREATE TABLE`: Creates a new table.
- `ALTER TABLE`: Modifies an existing table.
- `DROP TABLE`: Deletes a table.

- **DML (Data Manipulation Language):** Manages data within tables.


Commands include:
- `SELECT`: Retrieves data.
- `INSERT`: Adds new rows.
- `UPDATE`: Modifies existing rows.
- `DELETE`: Removes rows.

- **DCL (Data Control Language):** Manages permissions and access controls.


Commands include:
- `GRANT`: Gives privileges to users.
- `REVOKE`: Removes privileges.

- **TCL (Transaction Control Language):** Manages transactions in a database.


Commands include:
- `COMMIT`: Saves all changes.
- `ROLLBACK`: Undoes changes.
- `SAVEPOINT`: Sets a point in a transaction to roll back to.

6. **Explain in Detail DDL and Its Commands:**


DDL (Data Definition Language) is used to define and modify database
structures. Key commands include:

- `CREATE TABLE`: Defines a new table and its columns.


```sql
CREATE TABLE Employees (
EmpID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Salary DECIMAL(10, 2)
);
```

- `ALTER TABLE`: Changes the structure of an existing table, such as adding a


column or modifying a column's data type.
```sql
ALTER TABLE Employees
ADD Department VARCHAR(50);
```

- `DROP TABLE`: Deletes a table and its data permanently.


```sql
DROP TABLE Employees;
```

7. **Explain in Detail DML and Its Commands:**


DML (Data Manipulation Language) handles the manipulation of data within
tables. Key commands include:
- `SELECT`: Retrieves data from one or more tables.
```sql
SELECT * FROM Employees;
```

- `INSERT INTO`: Adds new rows to a table.


```sql
INSERT INTO Employees (EmpID, FirstName, LastName, Salary)
VALUES (1, 'John', 'Doe', 50000);
```

- `UPDATE`: Modifies existing rows in a table.


```sql
UPDATE Employees
SET Salary = 55000
WHERE EmpID = 1;
```

- `DELETE FROM`: Removes rows from a table.


```sql
DELETE FROM Employees
WHERE EmpID = 1;
```
8. **Write a Short Note on Logical Operators:**
Logical operators in SQL are used to combine multiple conditions in a `WHERE`
clause. They help in filtering data based on complex criteria:

- `AND`: Returns true if all conditions are true.


```sql
SELECT * FROM Employees
WHERE Department = 'Sales' AND Salary > 50000;
```

- `OR`: Returns true if at least one condition is true.


```sql
SELECT * FROM Employees
WHERE Department = 'Sales' OR Salary > 50000;
```

- `NOT`: Reverses the result of a condition.


```sql
SELECT * FROM Employees
WHERE NOT Department = 'Sales';
```

9. **Write a Short Note on Relational Operators:**


Relational operators in SQL are used to compare values and filter data based on
these comparisons. Common relational operators include:
- `=`: Equals
```sql
SELECT * FROM Employees
WHERE Salary = 50000;
```

- `<>` or `!=`: Not equals


```sql
SELECT * FROM Employees
WHERE Salary <> 50000;
```

- `>`: Greater than


```sql
SELECT * FROM Employees
WHERE Salary > 50000;
```

- `<`: Less than


```sql
SELECT * FROM Employees
WHERE Salary < 50000;
```
- `>=`: Greater than or equal to
```sql
SELECT * FROM Employees
WHERE Salary >= 50000;
```

- `<=`: Less than or equal to


```sql
SELECT * FROM Employees
WHERE Salary <= 50000;
```

10. **Explain in Detail Functions of SQL:**


SQL functions are used to perform operations on data and return results.
Functions can be categorized into:

- **Aggregate Functions:** Operate on a set of values and return a single value.


- `COUNT()`, `SUM()`, `AVG()`, `MIN()`, `MAX()`
- Example: `SELECT AVG(Salary) FROM Employees;`

- **Scalar Functions:** Operate on individual values and return a single value.


- `UPPER()`, `LOWER()`, `LENGTH()`, `SUBSTRING()`
- Example: `SELECT UPPER(FirstName) FROM Employees;`
- **Date Functions:** Perform operations on date and time values.
- `NOW()`, `DATEADD()`, `DATEDIFF()`
- Example: `SELECT DATEDIFF(CURDATE(), HireDate) FROM
Employees;`

11. **SQL Queries for the Given Relations:**

Given relations:
- `Supplier (S#, sname, status, city)`
- `Parts (P#, pname, color, weight, city)`
- `SP (S#, P#, quantity)`

a. SQL Queries:

(i) **Find name of suppliers for city = 'Delhi':**


```sql
SELECT sname
FROM Supplier
WHERE city = 'Delhi';
```

(ii) **Find suppliers whose name starts with 'AB':**


```sql
SELECT sname
FROM Supplier
WHERE sname LIKE 'AB%';
```

(iii) **Find all suppliers whose status is 10, 20, or 30:**


```sql
SELECT sname
FROM Supplier
WHERE status IN (10, 20, 30);
```

(iv) **Find the total number of cities of all suppliers:**


```sql
SELECT COUNT(DISTINCT city) AS TotalCities
FROM Supplier;
```

(v) **Find S# of suppliers who supply ‘red’ part:**


```sql
SELECT DISTINCT S#
FROM SP
JOIN Parts ON SP.P# = Parts.P#
WHERE Parts.color = 'red';
```
(vi) **Count number of suppliers who supply ‘red’ part:**
```sql
SELECT COUNT(DISTINCT S#) AS SupplierCount
FROM SP
JOIN Parts ON SP.P#.
Unit 3.

### Short Questions

**23. Define Data Models and Enlist the Different Data Models.**

- **Data Models**: Data models define how data is connected, stored, and
accessed. They provide a conceptual framework for organizing and managing data.
Data models abstract and simplify complex data structures to make it easier for
users to understand and manipulate the data.

- **Different Data Models**:


- **Hierarchical Model**: Organizes data in a tree-like structure, where each
record has a single parent and potentially many children.
- **Network Model**: Similar to the hierarchical model but allows more
complex relationships with multiple parent records.
- **Relational Model**: Uses tables to represent data and relationships between
data, with a focus on data integrity and flexibility.
- **Object-Oriented Model**: Integrates object-oriented programming principles
with database technology, allowing for complex data types and relationships.
- **Entity-Relationship Model**: Uses entities and relationships to model real-
world data and interactions.
**24. Give the Disadvantages of Hierarchical Data Model**

- **Complexity in Data Retrieval**: Traversing the tree structure can be complex,


especially when retrieving data from various levels.
- **Rigidity**: The structure is rigid; any changes in data requirements often
require significant restructuring of the hierarchy.
- **Limited Flexibility**: Difficult to represent many-to-many relationships
without creating complex hierarchies.
- **Data Redundancy**: May lead to data redundancy and inconsistency due to
multiple paths leading to the same data.

**25. Give the Advantages of Network Model**

- **Flexibility**: Allows more complex relationships between data elements,


supporting many-to-many relationships.
- **Efficient Data Retrieval**: Provides direct access paths, which can make
querying and data retrieval more efficient.
- **Avoids Redundancy**: Can reduce data redundancy compared to the
hierarchical model by using multiple parent-child relationships.
- **Improved Data Integrity**: Enforces data integrity through explicit
relationships and constraints.

**26. Give a Brief About Relational Data Model**

The **Relational Data Model** organizes data into tables (relations), each with
rows (tuples) and columns (attributes). Tables can be linked using keys, such as
primary and foreign keys, which ensure that relationships between tables are
consistent. This model emphasizes data integrity and flexibility, allowing users to
query and manipulate data using a high-level query language like SQL. The
relational model supports operations such as selection, projection, and join, making
it a powerful tool for managing and analyzing data.

### Long Questions

**27. Difference Between Hierarchical Model, Network Model, and Relational


Model**

- **Hierarchical Model**:
- **Structure**: Tree-like hierarchy with a single parent-child relationship.
- **Relationships**: One-to-many relationships.
- **Flexibility**: Limited; rigid structure.
- **Complexity**: Higher complexity for retrieval due to hierarchical navigation.

- **Network Model**:
- **Structure**: Graph-like structure with multiple parent-child relationships.
- **Relationships**: Many-to-many relationships are supported.
- **Flexibility**: Greater than hierarchical model.
- **Complexity**: More complex relationships and data retrieval compared to
hierarchical.

- **Relational Model**:
- **Structure**: Data is organized into tables with rows and columns.
- **Relationships**: Supports one-to-one, one-to-many, and many-to-many
relationships through foreign keys.
- **Flexibility**: Highly flexible; changes in data structure do not require
reorganization of the database.
- **Complexity**: Simplifies data management and retrieval through SQL.

**28. What is Mapping Cardinalities? Explain it with Real-Time Examples**

**Mapping Cardinalities** describe the number of instances of one entity that can
or must be associated with each instance of another entity. There are several types:

- **One-to-One (1:1)**: Each instance of entity A is associated with one instance


of entity B and vice versa.
- *Example*: Each person has one passport, and each passport is assigned to one
person.

- **One-to-Many (1:N)**: Each instance of entity A can be associated with


multiple instances of entity B, but each instance of entity B is associated with only
one instance of entity A.
- *Example*: A single professor can teach multiple courses, but each course is
taught by only one professor.

- **Many-to-One (N:1)**: Multiple instances of entity A can be associated with a


single instance of entity B.
- *Example*: Many students can be enrolled in one course.
- **Many-to-Many (N:M)**: Multiple instances of entity A can be associated with
multiple instances of entity B.
- *Example*: Students can enroll in multiple courses, and each course can have
multiple students.

**29. Explain Types of Attributes with Example**

- **Simple Attribute**: Cannot be divided further.


- *Example*: A person's age (e.g., 25).

- **Composite Attribute**: Can be divided into smaller sub-parts.


- *Example*: An address can be divided into street, city, state, and zip code.

- **Derived Attribute**: Value can be derived from other attributes.


- *Example*: Age can be derived from a date of birth.

- **Multi-Valued Attribute**: Can hold multiple values.


- *Example*: A person’s phone numbers, where a person can have multiple phone
numbers.

**30. Explain Specialization Feature of E-R Diagram with Example**

**Specialization** is a process of defining a set of subclasses from a superclass


based on some distinguishing characteristics. It allows the creation of a more
specialized entity from a general one.
- *Example*: In a university database, a general entity "Person" could be
specialized into "Student" and "Faculty" entities. While "Person" might have
attributes like name and address, "Student" and "Faculty" will have additional
specific attributes like student ID and department or faculty rank and office
location.

**31. Explain Generalization Feature of E-R Diagram**

**Generalization** is the process of abstracting common features from multiple


subclasses into a superclass. It is the opposite of specialization and helps to
combine similar entities into a generalized entity.

- *Example*: Consider "Student" and "Faculty" entities, which can be generalized


into a common entity "Person." Both "Student" and "Faculty" share common
attributes like name and address, but have their specific attributes. Generalization
allows these common attributes to be represented in the "Person" superclass.

**32. Explain Aggregation Operation of E-R Diagram**

**Aggregation** is a concept in E-R diagrams used to simplify complex


relationships. It represents a higher-level abstraction of a relationship between
entities and is used when a relationship itself needs to be related to another entity.

- *Example*: Consider a "Project" entity that involves "Employee" and


"Department" entities. If a relationship between "Employee" and "Department"
needs to be associated with "Project," aggregation can be used to create a higher-
level abstraction that connects "Employee-Department" with "Project," simplifying
the diagram.
**33. Design an Entity-Relationship (E-R) Diagram for a Parul University
Database System**

- **Entities**:
- **Student**: Attributes - Student_ID (PK), Name, Date_of_Birth, Email
- **Course**: Attributes - Course_ID (PK), Course_Name, Credits
- **Faculty**: Attributes - Faculty_ID (PK), Name, Department, Email
- **Department**: Attributes - Department_ID (PK), Department_Name,
Building

- **Relationships**:
- **Enroll** (between Student and Course): Many-to-Many (Students can enroll
in many courses, and each course can have many students)
- **Teaches** (between Faculty and Course): One-to-Many (A faculty can teach
many courses, but each course is taught by one faculty)
- **Belongs_to** (between Course and Department): Many-to-One (A course
belongs to one department, but a department can have multiple courses)

- **Cardinalities**:
- **Enroll**: Student (N) to Course (M)
- **Teaches**: Faculty (1) to Course (N)
- **Belongs_to**: Course (N) to Department (1)

The E-R diagram will include entities with their attributes and relationships with
their cardinalities, making it a comprehensive representation of the Parul
University database system.
**Unit 4**

**Short Questions:**

34. **Define the NOT NULL constraint and give an example of its use.**
- The NOT NULL constraint ensures that a column cannot have NULL values.
This is used to ensure that a column always has a value and cannot be left empty.
- **Example:** `CREATE TABLE Employees (EmployeeID INT NOT NULL,
Name VARCHAR(100) NOT NULL, Department VARCHAR(50));`

35. **How does a check constraint enhance data integrity in databases?**


- A CHECK constraint ensures that values in a column meet a specific condition.
This helps maintain data integrity by enforcing rules about the data values. For
example, a CHECK constraint can ensure that ages are within a certain range or
that salary values are positive.

36. **Describe the selection operation in relational algebra.**


- The selection operation (σ) in relational algebra filters rows based on a
specified condition. It returns a subset of tuples from a relation that satisfy the
condition.
- **Example:** `σ (age > 30) (Employees)` retrieves all employees older than
30.

37. **What are aggregate functions in SQL and give examples of their usage?**
- Aggregate functions perform a calculation on a set of values and return a single
value. Common aggregate functions include:
- `COUNT(column_name)` - Counts the number of rows.
- `SUM(column_name)` - Adds up the values in a column.
- `AVG(column_name)` - Calculates the average value of a column.
- `MAX(column_name)` - Finds the maximum value in a column.
- `MIN(column_name)` - Finds the minimum value in a column.
- **Example:** `SELECT AVG(salary) FROM Employees;`

38. **What is the relational data model and how does it organize data?**
- The relational data model organizes data into tables (relations), each consisting
of rows (tuples) and columns (attributes). Each table represents an entity, with
columns representing attributes and rows representing records of that entity.
Relationships between tables are established through primary and foreign keys.

39. **Define the degree of a relation in the context of a relational database.**


- The degree of a relation refers to the number of attributes (columns) in a
relation (table). For example, if a table has three columns, its degree is 3.

40. **Explain cardinality constraints in the context of relational databases.**


- Cardinality constraints specify the number of instances of one entity that can or
must be associated with each instance of another entity. Common types are:
- **One-to-One (1:1)**: Each instance in a table A is related to one instance in
table B.
- **One-to-Many (1:N)**: Each instance in table A can be related to multiple
instances in table B.
- **Many-to-Many (M:N)**: Instances in table A can be related to multiple
instances in table B and vice versa.
**Long Questions:**

41. **Describe how the JOIN operation works in relational algebra. Provide
examples of different types of joins and when each is useful.**
- The JOIN operation combines rows from two or more tables based on a related
column.
- **Inner Join**: Combines rows from both tables that satisfy the join
condition.
- **Example:** `R1 ⨝ R2` where `R1` and `R2` are two relations and the join
condition is specified.
- **Left Outer Join**: Includes all rows from the left table and matching rows
from the right table; rows from the left table with no match in the right table will
have NULL values for right table columns.
- **Example:** `R1 ⟕ R2`
- **Right Outer Join**: Includes all rows from the right table and matching
rows from the left table; rows from the right table with no match in the left table
will have NULL values for left table columns.
- **Example:** `R1 ⟖ R2`
- **Full Outer Join**: Includes rows when there is a match in one of the tables.
- **Example:** `R1 ⟗ R2`
- **Cross Join**: Returns the Cartesian product of the two tables.
- **Example:** `R1 × R2`

42. **Discuss the purpose of constraints in database management. Explain all


constraints with appropriate examples.**
- Constraints ensure data integrity and enforce rules on the data within a
database. Types of constraints include:
- **Primary Key**: Ensures each row in a table is unique and identifiable.
- **Example:** `PRIMARY KEY (EmployeeID)`
- **Foreign Key**: Ensures referential integrity by linking columns to a
primary key in another table.
- **Example:** `FOREIGN KEY (DepartmentID) REFERENCES
Departments(DepartmentID)`
- **Unique**: Ensures all values in a column are unique.
- **Example:** `UNIQUE (Email)`
- **Not Null**: Ensures that a column cannot have NULL values.
- **Example:** `NOT NULL (Name)`
- **Check**: Ensures values in a column satisfy a specific condition.
- **Example:** `CHECK (Age > 0)`
- **Default**: Provides a default value for a column if none is specified.
- **Example:** `DEFAULT ('N/A')`

43. **Explain the following terms with a suitable example:**


- **Primary Key**: A unique identifier for each row in a table.
- **Example:** In a table `Students`, `StudentID` can be a primary key.
- **Candidate Key**: A column or set of columns that can uniquely identify a
row in a table. A table may have multiple candidate keys.
- **Example:** In a table `Students`, both `StudentID` and `Email` could be
candidate keys.
- **Foreign Key**: A column in one table that uniquely identifies a row in
another table, enforcing referential integrity.
- **Example:** In a table `Enrollments`, `StudentID` might be a foreign key
referring to `StudentID` in the `Students` table.
44. **Explain selection and projection operations with examples.**
- **Selection (σ)**: Retrieves rows from a table that meet a specific condition.
- **Example:** `σ (age > 30) (Employees)` selects employees older than 30.
- **Projection (π)**: Retrieves specific columns from a table.
- **Example:** `π (Name, Age) (Employees)` retrieves only the `Name` and
`Age` columns from the `Employees` table.

45. **What is database schema? Explain the select, project, natural join, union, and
Cartesian product operations.**
- **Database Schema**: The structure of a database described in a formal
language, including tables, columns, and relationships.
- **Select (σ)**: Filters rows based on a condition.
- **Example:** `σ (Salary > 50000) (Employees)`
- **Project (π)**: Retrieves specific columns from a table.
- **Example:** `π (Name, Department) (Employees)`
- **Natural Join (⨝)**: Joins tables based on common columns, combining
rows with equal values in those columns.
- **Example:** `Employees ⨝ Departments` combines employee data with
department data based on department IDs.
- **Union (∪)**: Combines rows from two tables, eliminating duplicates.
- **Example:** `Employees ∪ Contractors`
- **Cartesian Product (×)**: Returns all possible combinations of rows from two
tables.
- **Example:** `Employees × Departments` returns all possible combinations
of employees and departments.
46. **Consider the following schema and represent given statements in relational
algebra form:**
- **Schema:**
- `Branch(branch_name, branch_city)`
- `Account(branch_name, acc_no, balance)`
- `Depositor(Customer_name, acc_no)`
- **(i) Find out list of customers who have an account at the 'abc' branch.**
- **Relational Algebra:** `π (Customer_name) (σ (branch_name = 'abc')
(Account) ⨝ Depositor)`
- **(ii) Find out all customers who have an account in the 'Ahmedabad' city and
balance is greater than 10,000.**
- **Relational Algebra:** `π (Customer_name) (σ (balance > 10000) (Account)
⨝ (σ (branch_city = 'Ahmedabad') (Branch) ⨝ Account) ⨝ Depositor)`
- **(iii) Find out list of all branch names with their maximum balance.**
- **Relational Algebra:** `π (branch_name, balance) (Account ⨝ (π
(branch_name, max_balance) (Account ⨝ (π (branch_name, MAX(balance) as
max_balance) (Account))))`

47. **Describe how the Set operation works in relational algebra.**


- **Set Operations**: Operate on relations as sets. They include:
- **Union (∪)**: Combines tuples from two relations, removing duplicates.

- **Intersection (∩)**: Retrieves tuples that are common to both relations.

- **Difference (−)**: Retrieves tuples from the first relation that are not in the
second.
- **Cartesian Product (×)**: Returns all possible combinations of tuples from
two relations.

Unit 5.

### Short Questions

**48. Define functional dependency. Explain trivial and non-trivial FD with


example.**

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


database relation. An attribute set X functionally determines another attribute set Y
if, for any two tuples in the relation, if they agree on attributes in X, they must also
agree on attributes in Y. This is denoted as \( X \rightarrow Y \).

- **Trivial Functional Dependency**: An FD \( X \rightarrow Y \) is


considered trivial if \( Y \) is a subset of \( X \). In other words, the
dependency is trivial if the dependent attributes are already included in the
determining attributes.

*Example*: For a relation with attributes \( A \) and \( B \), \( A \rightarrow A \) is


trivial because \( A \) is a subset of itself.

- **Non-Trivial Functional Dependency**: An FD \( X \rightarrow Y \) is


non-trivial if \( Y \) is not a subset of \( X \). This means the dependent
attributes are not contained within the determining attributes.
*Example*: For the same relation, \( A \rightarrow B \) is non-trivial if \( B \) is
not part of \( A \).

**49. What do you Mean by Functional Dependency?**

Functional Dependency (FD) describes a relationship between attributes in a


relational database. Specifically, it indicates that the value of one set of attributes
(the determinant) uniquely determines the value of another set of attributes. In
other words, if two tuples agree on the values of the determinant attributes, they
must also agree on the values of the dependent attributes. This concept is
fundamental in database normalization and helps ensure data integrity.

### Long Questions

**50. Given relation R with attributes A, B, C, D, E, F and set of FDs as \( A


\rightarrow BC \), \( E \rightarrow CF \), \( B \rightarrow E \), and \( CD
\rightarrow EF \). Find out closure of FD.**

To find the closure of a set of functional dependencies, you need to compute all the
attributes that can be functionally determined by a given attribute set.

Let’s find the closure of the functional dependencies step by step:

1. **Start with the given FDs**: \( A \rightarrow BC \), \( E \rightarrow CF \),


\( B \rightarrow E \), and \( CD \rightarrow EF \).

2. **Find the closure of each FD**:


- \( A^+ \): Starting with \( A \):
- \( A \rightarrow BC \), so add \( B \) and \( C \) to \( A^+ \).
- Next, \( B \rightarrow E \), so add \( E \) to \( A^+ \).
- \( E \rightarrow CF \), so add \( C \) and \( F \) to \( A^+ \).
- Now \( CD \rightarrow EF \) but \( CD \) isn’t in \( A^+ \) yet, so we do not
add more.
- Closure of \( A \) is \( \{A, B, C, E, F\} \).

- \( B^+ \): Starting with \( B \):


- \( B \rightarrow E \), so add \( E \) to \( B^+ \).
- \( E \rightarrow CF \), so add \( C \) and \( F \) to \( B^+ \).
- \( CD \rightarrow EF \) but \( CD \) isn’t in \( B^+ \), so no further additions.
- Closure of \( B \) is \( \{B, E, C, F\} \).

- \( C^+ \): Starting with \( C \):


- There are no direct FDs from \( C \), so \( C^+ \) is \( \{C\} \).

- \( D^+ \): Starting with \( D \):


- There are no direct FDs from \( D \), so \( D^+ \) is \( \{D\} \).

- \( E^+ \): Starting with \( E \):


- \( E \rightarrow CF \), so add \( C \) and \( F \) to \( E^+ \).
- \( CD \rightarrow EF \) but \( CD \) isn’t in \( E^+ \), so no further additions.
- Closure of \( E \) is \( \{E, C, F\} \).
- \( CD^+ \): Starting with \( CD \):
- \( CD \rightarrow EF \), so add \( E \) and \( F \) to \( CD^+ \).
- From \( E \rightarrow CF \), add \( C \) and \( F \) to \( CD^+ \) (already
included).
- Closure of \( CD \) is \( \{C, D, E, F\} \).

- \( A, B^+ \): Combine the closures:


- \( A^+ = \{A, B, C, E, F\} \) and \( B^+ = \{B, E, C, F\} \).
- The combined closure of \( A, B \) would be \( \{A, B, C, E, F\} \), which is
the same as \( A^+ \).

**51. What is inference rules/Armstrong’s axioms?**

Armstrong’s axioms are a set of inference rules used to derive all functional
dependencies implied by a given set of functional dependencies. They help in
reasoning about FDs and ensuring completeness and consistency in relational
database design. The axioms are:

1. **Reflexivity**: If \( Y \subseteq X \), then \( X \rightarrow Y \).


2. **Augmentation**: If \( X \rightarrow Y \), then \( XZ \rightarrow YZ \) for any
attribute set \( Z \).
3. **Transitivity**: If \( X \rightarrow Y \) and \( Y \rightarrow Z \), then \( X
\rightarrow Z \).

These rules are used to derive additional functional dependencies and to check
whether a given functional dependency is implied by a set of functional
dependencies.
**52. Let \( R = (A, B, C, D, E, F) \) be a relation scheme with the following
dependencies:
\( C \rightarrow F \),
\( E \rightarrow A \),
\( EC \rightarrow D \),
\( A \rightarrow B \). Find the closure of FD.**

To find the closure of these functional dependencies:

1. **Start with the given FDs**: \( C \rightarrow F \), \( E \rightarrow A \), \(


EC \rightarrow D \), \( A \rightarrow B \).

2. **Find the closure of each FD**:


- **Closure of \( C^+ \)**:
- \( C \rightarrow F \)
- Closure of \( C \) is \( \{C, F\} \).

- **Closure of \( E^+ \)**:


- \( E \rightarrow A \)
- \( A \rightarrow B \) (transitive from \( E \))
- Closure of \( E \) is \( \{E, A, B\} \).

- **Closure of \( EC^+ \)**:


- \( E \rightarrow A \), \( A \rightarrow B \)
- \( C \rightarrow F \)
- \( EC \rightarrow D \)
- Closure of \( EC \) is \( \{E, C, A, B, F, D\} \).

- **Closure of \( A^+ \)**:


- \( A \rightarrow B \)
- \( E \rightarrow A \) is not directly used here.
- Closure of \( A \) is \( \{A, B\} \).

Combining these findings, the closure of the complete set of functional


dependencies involves ensuring that all attributes are covered by applying the
inference rules appropriately.

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