0% found this document useful (0 votes)
20 views31 pages

Dbms pt1

Shshsh

Uploaded by

aatifdjhs80
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)
20 views31 pages

Dbms pt1

Shshsh

Uploaded by

aatifdjhs80
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/ 31

Program: Computer Engineering Semester: III

Course: Database Management System

Question Bank:
1-Give the Drawbacks of File Processing System?
1. Ans-Data Redundancy: In FPS, the same data may be stored in multiple files, leading to
duplication and wastage of storage space12.

2. Data Inconsistency: Due to data redundancy, different files may contain different
values for the same data, causing inconsistencies12.

3. Limited Data Sharing: Sharing data between different applications or users is difficult
because files are often isolated and not integrated23.

4. Poor Data Integrity: Ensuring data integrity is challenging as there are no centralized
constraints or rules to enforce data accuracy and consistency1.

5. Security Issues: FPS lacks robust security measures, making it difficult to control
access to sensitive data3.

6. Atomicity Problems: Ensuring that all parts of a transaction are completed


successfully or none at all is difficult in FPS1.

7. Data Isolation: Data is scattered in various files, making it hard to retrieve and
combine data from different sources12.

8. Program Maintenance: Maintaining and updating programs to handle data in FPS is


time-consuming and labor-intensive1.

9. Accessing Anomalies: Retrieving data in a specific format or manner often requires


writing new programs, which is inefficient1.

These drawbacks highlight why many organizations have transitioned to using DBMS, which
offers more efficient, secure, and reliable data management.

2-Define the following terms:


DBMS, Database, query, tables, records, key, candidate key, foreign key, primary key, Query,
DDL, DML?

1. Ans-DBMS (Database Management System): A software system that enables the creation,
management, and manipulation of databases. It provides tools for data storage, retrieval, and
management, ensuring data integrity, security, and consistency.
2. Database: An organized collection of structured data, typically stored electronically in
a computer system. A database allows for efficient data retrieval, insertion, and
management.

3. Query: A request for data or information from a database. Queries are written in a
specific language, such as SQL, to retrieve, update, or manipulate data.

4. Tables: Structures within a database that organize data into rows and columns. Each
table represents a specific entity, with columns representing attributes and rows
representing records.

5. Records: Individual entries in a table, also known as rows. Each record contains data
for a specific instance of the entity represented by the table.

6. Key: An attribute or a set of attributes that uniquely identifies a record in a table. Keys
are used to establish and enforce relationships between tables.

7. Candidate Key: An attribute or a set of attributes that can uniquely identify a record
in a table. A table can have multiple candidate keys, but only one can be chosen as
the primary key.

8. Foreign Key: An attribute or a set of attributes in one table that references the
primary key of another table. Foreign keys are used to establish relationships
between tables and ensure referential integrity.

9. Primary Key: A specific candidate key chosen to uniquely identify records in a table.
The primary key must contain unique values and cannot contain NULL values.

10. DDL (Data Definition Language): A subset of SQL used to define and manage
database structures, such as creating, altering, and deleting tables and other
database objects. Examples include CREATE, ALTER, and DROP.

11. DML (Data Manipulation Language): A subset of SQL used to manipulate data within
database tables. It includes commands for inserting, updating, deleting, and
retrieving data. Examples include INSERT, UPDATE, DELETE, and SELECT.

3-Give the advantages of DBMS over file processing system?

1. Ans-Data Redundancy and Inconsistency: DBMS minimizes data


redundancy by storing data in a centralized database, ensuring
consistency. In contrast, FPS often leads to data duplication and
inconsistencies12.

2. Data Sharing: DBMS allows multiple users and applications to access and
share data concurrently, while FPS makes data sharing complex and less
efficient12.
3. Data Integrity: DBMS enforces data integrity through constraints and
rules, ensuring data accuracy and consistency. FPS lacks automated
integrity checks, leading to potential errors2.
4. Data Security: DBMS provides robust security features, including user
authentication, authorization, and encryption, protecting sensitive data.
FPS generally lacks these advanced security measures2.

5. Data Concurrency: DBMS supports concurrent access to data by multiple


users, using mechanisms like locking to prevent conflicts. FPS struggles
with concurrent access, leading to potential data anomalies1.

6. Data Backup and Recovery: DBMS offers automated backup and


recovery options, ensuring data can be restored in case of failures. FPS
relies on manual backup procedures, which are more prone to data loss2.

7. Efficient Data Access: DBMS uses indexing, caching, and query


optimization techniques to retrieve data efficiently. FPS requires writing
specific programs for each data retrieval task2.

8. Data Manipulation: DBMS provides powerful data manipulation


capabilities through SQL, allowing complex queries and operations. FPS
requires custom programs for data manipulation2.

9. Scalability: DBMS can handle large datasets and scale efficiently as data
grows, while FPS may struggle with performance and management as
data volume increases2.

5-Describe Functional dependency in DBMS?


Ans-Definition
A functional dependency (FD) is a constraint between two sets of
attributes in a relation from a database. It specifies that the value of
one attribute (or a group of attributes) determines the value of
another attribute (or a group of attributes). It is denoted by an arrow
(→).
Notation
If attribute ( X ) determines attribute ( Y ), it is written as: [ X
\rightarrow Y ]
Example
Consider a table with attributes EmployeeID, EmployeeName, and
Department. If EmployeeID uniquely
determines EmployeeName and Department, we can write: [
\text{EmployeeID} \rightarrow \text{EmployeeName},
\text{Department} ]
Types of Functional Dependencies
1. Trivial Functional Dependency:
o A functional dependency is trivial if the dependent
attribute is a subset of the determinant attribute.
o Example: ( \text{EmployeeID, EmployeeName} \rightarrow
\text{EmployeeID} )
2. Non-Trivial Functional Dependency:
o A functional dependency is non-trivial if the dependent
attribute is not a subset of the determinant attribute.
o Example: ( \text{EmployeeID} \rightarrow
\text{EmployeeName} )
3. Transitive Dependency:
oIf ( X \rightarrow Y ) and ( Y \rightarrow Z ), then ( X
\rightarrow Z ) is a transitive dependency. o Example:
If EmployeeID determines Department and Department
d etermines Manager, then EmployeeID determines
Manager.
4. Multivalued Dependency:
o A multivalued dependency occurs when one attribute
determines a set of values for another attribute.
o Example: If EmployeeID determines multiple ProjectIDs,
then EmployeeID has a multivalued dependency on
ProjectID.
Importance
Functional dependencies are crucial for:
• Normalization: Ensuring that the database is free from
anomalies and redundancy.
• Data Integrity: Maintaining the accuracy and consistency of
data.
• Database Design: Helping in the design of efficient and effective
database schemas.

6-Explain database instance & database schema with suitable


example
Ans-Database Schema
• Definition: A database schema is the blueprint or architecture
of a database. It defines how data is organized and how the
relationships among data are associated. It includes definitions
of tables, columns, data types, indexes, and constraints.
• Example: Imagine a database for a school. The schema might
include tables like Students, Teachers, and Classes. Each table
has columns with specific data types and constraints. For
instance:
o Students Table:
 StudentID (Primary Key)
 Name
 DateOfBirth
 ClassID (Foreign Key referencing Classes table)
o Teachers Table:
 TeacherID (Primary Key)
 Name
 Subject o Classes Table:
 ClassID (Primary Key)
 ClassName
 TeacherID (Foreign Key referencing Teachers
table) Database Instance
• Definition: A database instance is the actual data stored in the
database at a particular moment in time. It is a snapshot of the
database, including all the data in the tables as defined by the
schema.
• Example: Continuing with the school database example, an
instance might look like this:
o Students Table:
 StudentID: 1, Name: John Doe, DateOfBirth:
2005-
06-15, ClassID: 101
 StudentID: 2, Name: Jane Smith, DateOfBirth:
2006-
08-22, ClassID: 102 o
Teachers Table:
 TeacherID: 1, Name: Mr. Brown, Subject: Math
 TeacherID: 2, Name: Ms. Green, Subject:
Science o Classes Table:
 ClassID: 101, ClassName: Math 101, TeacherID:
1
 ClassID: 102, ClassName: Science 101,
TeacherID: 2
Key Differences
• Schema: Defines the structure and organization of the database
(e.g., tables, columns, relationships).
• Instance: Represents the actual data stored in the database at a
specific point in time

9- Describe the role or functions of Database administrator


Ans- A Database Administrator (DBA) plays a crucial role in managing
and maintaining an organization’s database systems. Here are some
of the key functions and responsibilities of a DBA:
1. Database Design and Implementation:
o Design: Creating the database structure, including tables,
indexes, and relationships.
o Implementation: Setting up the database according to the
design specifications.
2. Installation and Configuration:
o Installation: Installing database software and related
tools.
o Configuration: Configuring the database environment to
meet the organization’s needs.
3. Performance Monitoring and Tuning:
o Monitoring: Continuously monitoring database
performance to identify and resolve issues.
o Tuning: Optimizing database performance through
indexing, query optimization, and resource allocation.
4. Security Management:
o Access Control: Managing user access and permissions to
ensure data security.
o Encryption: Implementing encryption and other security
measures to protect sensitive data.
5. Backup and Recovery:
o Backup: Creating regular backups of the database to
prevent data loss.
o Recovery: Developing and implementing recovery plans to
restore data in case of failures.
6. Data Integrity and Consistency:
o Integrity: Ensuring data integrity by enforcing constraints
and validation rules.
o Consistency: Maintaining data consistency across different
database instances.
7. Database Maintenance:
o Housekeeping: Performing routine maintenance tasks
such as updating statistics, rebuilding indexes, and
cleaning up logs.
o Upgrades: Applying patches and upgrades to the database
software.
8. Troubleshooting and Support:
o Troubleshooting: Identifying and resolving
databaserelated issues.
o Support: Providing support to developers and end-users
for database-related queries and problems.
9. Capacity Planning:
o Planning: Estimating future database storage
requirements and planning for capacity expansion.
o Scaling: Implementing strategies to scale the database as
needed.
10. Documentation and Reporting:
o Documentation: Maintaining comprehensive
documentation of database configurations, procedures,
and policies.
o Reporting: Generating reports on database performance,
usage, and other metrics.
11. Collaboration with Development Teams:
o Design Support: Assisting developers in designing efficient
database schemas and queries.
o Testing: Supporting database testing and deployment
processes.
12. Compliance and Auditing:
o Compliance: Ensuring that the database complies with
relevant regulations and standards.
o Auditing: Conducting regular audits to monitor database
activities and ensure compliance
1. 10- Describe diverse types of database users Ans- Database
Administrators (DBA):
o Role: DBAs are responsible for managing the overall
database environment. They define the schema, control
access, ensure data integrity, perform backups, and
handle recovery.
o Example: A DBA might set up user accounts, grant
permissions, and monitor database performance.
2. Naive/Parametric Users:
o Role: These users interact with the database through
predefined applications without knowing the underlying
database structure. They perform routine tasks using
simple queries.
o Example: Bank clerks using a banking application to
update customer accounts.
3. System Analysts:
o Role: System analysts analyze the requirements of end
users and design systems to meet those needs. They
bridge the gap between users and developers.
o Example: An analyst might gather requirements for a new
inventory management system and design its
specifications.
4. Sophisticated Users:
o Role: These users are familiar with the database and can
write their own queries to retrieve data. They often use
advanced tools and techniques.
o Example: Data scientists running complex queries to
analyze large datasets.
5. Database Designers:
o Role: Database designers create the database schema,
including tables, indexes, views, and constraints. They
ensure the database structure meets the needs of all user
groups.
o Example: A designer might create a schema for a new
ecommerce platform, defining tables for products,
customers, and orders.
6. Application Programmers:
o Role: Also known as back-end developers, they write
application code that interacts with the database. They
develop and maintain database-driven applications.
o Example: A programmer might develop a web application
that allows users to search for and purchase products.
7. Casual Users:
o Role: These users access the database occasionally and
may use query languages to retrieve data. They do not
interact with the database regularly.
o Example: A manager running monthly reports to review
sales performance.
8. Specialized Users:
o Role: These users write specialized database applications
that are not part of the standard database system. They
often work on complex tasks requiring deep database
knowledge.
o Example: A researcher developing a custom application to
analyze genomic data.
12- Describe various DDL and DML commands
Ans-
Data Definition Language (DDL)
DDL commands are used to define and manage database schema
objects. They deal with the structure of the database and include:

1. CREATE: This command is used to create new database objects such as


tables, indexes, views, and schemas.
ALTER: This command modifies the structure of an existing database
object. It can be used to add, delete, or modify columns in a table.
DROP: This command removes an existing database object. It will delete
the object and all its data.
TRUNCATE: This command removes all records from a table but retains
the structure of the table for future use. It's faster than deleting rows
one by one but does not trigger any DELETE triggers.
RENAME: This command changes the name of an existing database
object.
Sure, I'd be happy to explain the different types of SQL commands used
in databases. SQL (Structured Query Language) is divided into several
categories based on what the commands are used for. The two main
categories are Data Definition Language (DDL) and Data Manipulation
Language (DML).
Data Definition Language (DDL)
DDL commands are used to define and manage database schema
objects. They deal with the structure of the database and include:
1. CREATE: This command is used to create new database objects such as
tables, indexes, views, and schemas. o Example:
sql
Copy code
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
HireDate DATE
);

2. ALTER: This command modifies the structure of an existing database


object. It can be used to add, delete, or modify columns in a table. o
Example:
sql
Copy code
ALTER TABLE Employees
ADD Email VARCHAR(100);

3. DROP: This command removes an existing database object. It will delete


the object and all its data.
o Example:
sql
Copy code
DROP TABLE Employees;

4. TRUNCATE: This command removes all records from a table but retains
the structure of the table for future use. It's faster than deleting rows
one by one but does not trigger any DELETE triggers.
o Example:
sql
Copy code
TRUNCATE TABLE Employees;

5. RENAME: This command changes the name of an existing database


object.
o Example:
sql
Copy code
RENAME TABLE Employees TO Staff;
Data Manipulation Language (DML)
DML commands are used to manage data within schema objects. They
deal with the data stored in the database and include:

1. SELECT: This command retrieves data from one or more tables. It can
include complex queries with filtering, sorting, and joining of tables.
INSERT: This command adds new rows to a table.
UPDATE: This command modifies existing rows in a table based on
specified criteria.
DELETE: This command removes rows from a table based on specified
criteria.

14- Draw and label all symbols of ER diagram

15- Explain Primary key and foreign key concepts in DBMS


with example
Ans- Primary Key
• Definition: A unique identifier for a record in a table. Each table
must have a primary key.
• Characteristics:
o Unique: No duplicate values allowed.
o Not NULL: Must always have a value.
Example:
CREATE TABLE Customers (
CustomerID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50)
);
Foreign Key
• Definition: A column in one table that links to the primary key
of another table. It establishes relationships between tables.
• Characteristics:
o References: Must match a value in the primary key
column of the referenced table or be NULL.
o CREATE TABLE Orders ( o OrderID INT PRIMARY KEY, o
OrderDate DATE, o CustomerID INT,
o FOREIGN KEY (CustomerID) REFERENCES
Customers(CustomerID) o );
16- Explain Super key and Candidate key concepts in
DBMS with example Ans-
Super Key
Definition: A super key is a set of one or more columns
(attributes) that can uniquely identify a record in a table.
A super key may contain additional attributes beyond
what is necessary to uniquely identify records.
Characteristics:
• Uniqueness: A super key ensures that no two rows have the
same values for the columns in the super key.
• Contains Candidate Keys: Every candidate key is a super key,
but not every super key is a candidate key.
Example: Consider a Students table:
• Students Table:
o StudentID (Unique Identifier)
o Email (Unique Identifier) o FirstName o LastName
Possible super keys include:
• {StudentID}
• {Email}
• {StudentID, Email}
• {StudentID, FirstName}
• {Email, LastName}
All these combinations can uniquely identify a record, but
they include more columns than necessary in some cases.
Candidate Key
Definition: A candidate key is a minimal super key,
meaning it is a super key with no redundant attributes.
Each candidate key is a set of columns that can uniquely
identify a record, and none of its attributes can be
removed without losing uniqueness.
Characteristics:
• Minimality: A candidate key contains only the necessary
attributes to ensure uniqueness.
• Uniqueness: Each candidate key uniquely identifies records in
the table.
Example: For the same Students table, assume:
• StudentID and Email are both unique identifiers and can each
individually identify a student.
Possible candidate keys are:
• {StudentID}
• {Email}
Both StudentID and Email are minimal super keys because
neither can be reduced further while maintaining
uniqueness.

17- Explain different Data types in SQL. Ans-


Numeric Data Types
1. INT:
o Description: Stores integer values.
o Example: INT (or INTEGER) o Range: Typically from -
2,147,483,648 to 2,147,483,647.
2. DECIMAL (or NUMERIC):
o Description: Stores exact numeric values with a
specified number of digits.
o Example: DECIMAL(10, 2) (10 total digits, 2 after
the decimal point)
o Range: Depends on precision and scale.
3. FLOAT:
o Description: Stores approximate numeric values
with floating decimal points. o Example: FLOAT
(precision may vary by database)
4. DOUBLE:
o Description: Stores approximate numeric values
with double precision.
o Example: DOUBLE (more precision than FLOAT)
Character Data Types
1. CHAR:
o Description: Stores fixed-length character strings.
o Example: CHAR(10) (always uses 10 characters,
padded with spaces if necessary)
2. VARCHAR:
o Description: Stores variable-length character
strings.
o Example: VARCHAR(255) (up to 255 characters) o
Usage: More flexible and space-efficient than
CHAR.
3. TEXT:
o Description: Stores large amounts of text data. o
Example: TEXT (can store long text strings) o Usage:
Suitable for large text fields. Date and Time Data
Types
1. DATE:
o Description: Stores date values. o Example: DATE
(format: YYYY-MM-DD)
2. TIME:
o Description: Stores time values.
o Example: TIME (format: HH:MM
)
3. DATETIME:
o Description: Stores date and time values.
o Example: DATETIME (format: YYYY-MM-DD HH:MM
)
4. TIMESTAMP:
o Description: Stores date and time with timezone
support (varies by database).
o Example: TIMESTAMP (often used for recording
changes to data)
5. YEAR:
o Description: Stores year values.
o Example: YEAR (format: YYYY) Binary Data Types
1. BLOB (Binary Large Object):
o Description: Stores large binary data, such as
images or files.
o Example: BLOB
2. VARBINARY:
o Description: Stores variable-length binary data. o
Example: VARBINARY(255) (up to 255 bytes)
Boolean Data Type

1. BOOLEAN:
o Description: Stores boolean values (true or false).
o Example: BOOLEAN (or BOOL, depending on the
database)
Miscellaneous Data Types
1. UUID:
o Description: Stores universally unique identifiers.
o Example: UUID (format: 36-character string)
2. ENUM:
o Description: Stores a value from a predefined list of
values. o Example: ENUM('red', 'green', 'blue')
3. SET:
o Description: Stores a set of predefined values.
o Example: SET('a', 'b', 'c') (can store any combination
of the defined values)
19- Describe aggregate functions with example
Ans- 1. COUNT
Description: Counts the number of rows in a set or
the number of non-NULL values in a column.
Example:
sql
SELECT COUNT(*) AS TotalEmployees
FROM Employees;
This query counts the total number of rows in the
Employees table.
Example with a specific column:
sql
SELECT COUNT(Email) AS EmailCount
FROM Employees;
This query counts the number of non-NULL values
in the Email column of the Employees table.
2. SUM
Description: Adds up all the values in a numeric
column. Example:
sql
SELECT SUM(Salary) AS TotalSalary
FROM Employees;
This query calculates the total sum of all salaries in
the Employees table.
3. AVG
Description: Calculates the average value of a
numeric column.
Example:
sql
SELECT AVG(Salary) AS AverageSalary
FROM Employees;
This query computes the average salary of all
employees in the Employees table.
4. MIN
Description: Returns the smallest value in a
column. Example:
sql
SELECT MIN(Salary) AS LowestSalary
FROM Employees;
This query finds the lowest salary in the Employees
table.
5. MAX
Description: Returns the largest value in a column.
Example:
sql
SELECT MAX(Salary) AS HighestSalary
FROM Employees;
This query finds the highest salary in the Employees
table.
6. GROUP_CONCAT (MySQL) /
STRING_AGG (PostgreSQL)
Description: Concatenates values from multiple
rows into a single string.
Example in MySQL:
sql
SELECT GROUP_CONCAT(FirstName) AS
AllFirstNames
FROM Employees;
This query concatenates all FirstName values into a
single comma-separated string.
Example in PostgreSQL:
sql
SELECT STRING_AGG(FirstName, ', ') AS
AllFirstNames
FROM Employees;
This query performs a similar operation in
PostgreSQL, concatenating FirstName values with a
comma and space separator.
7. VARIANCE / STDDEV
Description: Measures the statistical variance and
standard deviation of a numeric column.
Example for variance:
sql
SELECT VARIANCE(Salary) AS SalaryVariance
FROM Employees;
This query calculates the variance of salaries in the
Employees table.
Example for standard deviation:
sql
SELECT STDDEV(Salary) AS SalaryStdDev
FROM Employees;
This query calculates the standard deviation of
salaries.

1. 20-Explain 1NF with example. (6/8 MARKS) 5. Explain 2NF


with example. (6/8 MARKS)
Ans-"1 NF" stands for First Normal Form in database
normalization. It's the first step in organizing a database to
reduce redundancy and improve data integrity.
Key Rules of 1 NF:
1. Atomicity: Each column should contain atomic (indivisible)
values. This means that each field should hold only a single
value, not a set of values or a list.
2. Uniqueness of Rows: Each row in the table must be unique.
This can be achieved by ensuring that there's a primary key or
unique identifier for each record.
3. No Repeating Groups: There should be no repeating groups of
data within a row. Each piece of data must be stored in its own
column.
Example:
Let's consider a simple table that doesn't comply with 1
NF:
StudentID Name Subjects

Math, English,
1 Alice
History

2 Bob Science, Math


In this example:
 The "Subjects" column contains multiple values (e.g., "Math,
English, History"), which violates the atomicity rule.
 The data is not in 1 NF because it has repeating groups in the
"Subjects" column.
Converting to 1 NF:
To convert this table to 1 NF, we need to break down the
"Subjects" column into separate rows:
StudentID Name Subject

1 Alice Math

1 Alice English

1 Alice History
StudentID Name Subject

2 Bob Science

2 Bob Math
Now:
 Each column contains only atomic values.
 There are no repeating groups.
 Each row is unique.
This table is now in First Normal Form (1 NF).

2nf*
Second Normal Form (2NF) builds on the rules of First
Normal Form (1NF) and adds further requirements to
reduce redundancy and improve data integrity. To be in
2NF, a table must first be in 1NF, and then it must satisfy
the following conditions:
Key Rules of 2NF:
1. Meet the requirements of 1NF: The table must already be in
First Normal Form.
2. No Partial Dependency: Every non-key column must depend on
the entire primary key, not just a part of it. This rule applies
particularly when the primary key is composite (i.e., made up of
more than one column).
Example of a Table in 1NF but Not in 2NF:
Let's consider the table from the previous example,
assuming that a composite primary key consists of
StudentID and Subject.
Studen Na Subj Teac
tID me ect her

Mr.
Alic Mat
1 Smit
e h
h

Ms.
Alic Engli
1 John
e sh
son

Mr.
Alic Hist
1 Brow
e ory
n

Mr.
Bo Scie
2 Whit
b nce
e

Mr.
Bo Mat
2 Smit
b h
h
In this example:
 StudentID and Subject together form the composite primary
key.
 The Name column depends only on StudentID and not on the
entire primary key (i.e., it doesn't depend on Subject), which
creates a partial dependency.
 The Teacher column depends only on Subject and not on the
entire composite primary key.
Converting to 2NF:
To convert this table to 2NF, we need to eliminate partial
dependencies by separating the table into two or more
tables.
Table 1: Student Information (StudentID as Primary Key)
StudentID Name

1 Alice

2 Bob
Table 2: Subject Information (Subject as Primary Key)
Subject Teacher

Math Mr. Smith

English Ms. Johnson

History Mr. Brown

Science Mr. White


Table 3: Enrollment Information (Composite Key:
StudentID, Subject)
StudentID Subject

1 Math

1 English

1 History

2 Science

2 Math
Now:
 The Name column in the first table depends only on StudentID.
 The Teacher column in the second table depends only on
Subject.
 The third table represents the relationship between students
and their subjects.
This structure eliminates partial dependencies and brings
the data into Second Normal Form (2NF).

3nf*
Ans-Third Normal Form (3NF) builds on the rules of
Second Normal Form (2NF) and adds an additional
requirement to eliminate transitive dependencies. To be
in 3NF, a table must first be in 2NF, and then it must
satisfy the following condition:
Key Rule of 3NF:
1. Meet the requirements of 2NF: The table must already be in
Second Normal Form.
2. No Transitive Dependency: A non-key column must not depend
on another non-key column. In other words, all non-key
columns must depend only on the primary key, not on other
non-key columns.
Example of a Table in 2NF but Not in 3NF:
Let's continue with the previous example, but add a new
column that violates 3NF. Assume the Subject table is
extended with a new column Department that indicates
the department responsible for the subject.
Table: Subject Information (Subject as Primary Key)
Subject Teacher Department

Math Mr. Smith Science

English Ms. Johnson Arts

History Mr. Brown Humanities

Science Mr. White Science


In this example:
 Department depends on Subject, which is a non-key column.
 The Teacher column also depends on Subject.
This creates a transitive dependency: Department
depends on Subject, and Subject depends on the primary
key.
Converting to 3NF:
To bring this table into 3NF, we need to eliminate the
transitive dependency by creating a new table for the
Department information.
Table 1: Subject Information (Subject as Primary Key)
Subject Teacher

Math Mr. Smith

English Ms. Johnson

History Mr. Brown

Science Mr. White


Table 2: Department Information (Subject as Primary
Key)
Subject Department

Math Science

English Arts

History Humanities

Science Science
Now:
 The Teacher column depends only on Subject, and there are no
transitive dependencies in the Subject Information table.
 The Department information has been moved to its own table,
which keeps the data normalized.
This structure eliminates transitive dependencies and
brings the data into Third Normal Form (3NF).

----------------------THE END------------------------------

You might also like