DBMS
DBMS
✔ Data Organization: Stores data in structured formats like tables, records, and fields.
✔ Data Integrity: Ensures data accuracy and consistency using constraints.
✔ Data Security: Restricts access to authorized users.
✔ Data Independence: Changes in storage or structure do not affect applications.
✔ Concurrency Control: Multiple users can access the database simultaneously.
✔ Backup & Recovery: Ensures data safety in case of failures.
Data is stored in separate files for each Data is stored centrally in a structured
Storage
application database
Data Low (changes in one file may not reflect High (all applications access the same
Consistency in others) data)
Data Redundancy: The same data is stored multiple times, increasing storage requirements.
Data Inconsistency: If data is updated in one file but not in another, inconsistencies arise.
Security Risks: No access control mechanisms, making data vulnerable to unauthorized access.
Concurrency Issues: Multiple users cannot update the same file simultaneously.
Difficult Data Retrieval: Searching for specific data requires opening multiple files manually.
Example:
In a file-based system, an employee’s contact number is stored in multiple files (Payroll, HR,
Attendance). If the employee changes their number, it needs to be updated in all files separately,
leading to inconsistency if one file is missed.
4. Data Independence
Data Independence ensures that changes in database structure do not affect the application
programs that use the data.
Logical Data Independence: Changes in table structure do not affect user applications.
Physical Data Independence: Changes in storage format do not affect logical structure.
Example:
• If a new column "Email" is added to the Employee Table, the existing applications using the
table remain unaffected.
• If data storage changes from HDD to SSD, the logical structure of the database remains the
same.
6. DBMS Architecture
A DBMS follows a three-tier architecture that separates data access from storage for better
management.
1. External Level (User View):
• Defines how different users see the data.
• Example: A student sees only their exam results, while a teacher sees all students' results.
2. Conceptual Level (Logical Structure):
• Defines the relationships between data (tables, attributes, constraints).
• Example: A database has Students, Courses, and Teachers tables.
3. Internal Level (Storage Level):
• Manages how data is stored in memory.
• Example: Data is stored in indexes and files for faster access.
Diagram: DBMS Architecture
User (External Level)
↓
Logical Structure (Conceptual Level)
↓
Data Storage (Internal Level)
End Users: People who retrieve and update data (e.g., students checking results).
Application Programmers: Developers who create applications using the database.
Database Administrators (DBAs): Manage database security and performance.
System Analysts: Design and optimize database systems.
Conclusion
In this section, we explored:
✔ The difference between file-based and database-oriented approaches.
✔ The role of a Database Administrator (DBA) in managing databases.
✔ The three-tier DBMS architecture and different types of database users.
✔ Important database languages and their functions.
Section II: Relational Model and Database Design
1. Introduction to the Relational Model
The Relational Model is the most widely used database model today. It organizes data into tables
(relations) consisting of rows (tuples) and columns (attributes). Each table represents an entity,
and relationships between tables are defined using keys.
Example of a Relational Table: Student Table
Each row represents a unique student record, and each column represents an attribute of the
student.
Primary Key
The selected unique identifier for a table. Student_ID
(PK)
Foreign Key A key that refers to the Primary Key of another Student_ID in "Enrollment
(FK) table. Table"
1 101 DBMS
2 102 C++
Here, Student_ID in the Course Enrollment Table is a Foreign Key that references Student_ID in
the Student Table.
o Example: A course enrollment record cannot exist for a student ID that does not
exist in the Student Table.
4. Relational Algebra
Relational Algebra is a mathematical approach to manipulate and retrieve data in relational
databases.
2NF (Second Normal No partial Every non-key attribute depends on the whole
Form) dependencies primary key
3NF (Third Normal No transitive Every non-key attribute depends only on the
Form) dependencies primary key
BCNF (Boyce-Codd No non-trivial functional dependencies except
Stronger form of 3NF
NF) candidate keys
Retrieving Data:
SELECT Name, Age FROM Students WHERE Age > 20;
Inserting Data:
INSERT INTO Students (ID, Name, Age) VALUES (101, 'John Doe', 20);
Updating Data:
UPDATE Students SET Age = 21 WHERE ID = 101;
Deleting Data:
DELETE FROM Students WHERE ID = 101;
3. Nested Queries
A Nested Query is a query inside another query.
SELECT Name FROM Students WHERE ID IN (SELECT Student_ID FROM Enrollment WHERE
Course='DBMS');
This retrieves the names of students enrolled in the DBMS course.
Conclusion
In this section, we covered:
✔ The Relational Model and its importance in databases.
✔ Key concepts like Primary Keys, Foreign Keys, Integrity Rules.
✔ Relational Algebra for querying databases.
✔ Database Design using the ER Model.
✔ The process of Normalization to remove redundancy.
✔ SQL for querying and modifying relational data.
2. Functional Dependencies
Definition:
A functional dependency (FD) is a constraint between two sets of attributes in a relation. It states
that one attribute uniquely determines another.
Example:
In a Student Table,
Roll_No → Name, Age
• This means that for each Roll_No, we can determine the Name and Age.
Types of Functional Dependencies
Transitive
If A → B and B → C, then A → C. Roll_No → Hostel_ID → Room_No
Dependency
101 John
Course Table:
DB101 DBMS
C102 C++
101 DB101
101 C102
201 Alice D1 HR
202 Bob D2 IT
201 Alice D1
202 Bob D2
Department Table:
D1 HR
D2 IT
5. SQL Views
A View is a virtual table that stores query results without storing actual data.
Creating a View:
CREATE VIEW YoungStudents AS
SELECT Name, Age FROM Students WHERE Age < 21;
Using a View:
SELECT * FROM YoungStudents;
Advantages of Views:
6. Nested Queries
A Nested Query is a query inside another query.
SELECT Name FROM Students
WHERE Student_ID IN (SELECT Student_ID FROM Enrollment WHERE Course='DBMS');
This retrieves names of students enrolled in the DBMS course.
Conclusion
In this section, we covered:
✔ Functional Dependencies and their role in databases.
✔ Normalization techniques (1NF, 2NF, 3NF, BCNF) to remove redundancy.
✔ SQL operations for creating, modifying, and querying databases.
✔ Views and Nested Queries to optimize data retrieval.
5. Reports in FoxPro
FoxPro provides Report Generation Tools to create structured output.
Steps to Generate a Report:
1. Use the REPORT FORM command.
2. Define headers, footers, and fields to display.
3. Preview or print the report.
REPORT FORM StudentReport PREVIEW
Conclusion
In this section, we covered:
✔ FoxPro as an RDBMS and its database construction.
✔ Searching, Sorting, Indexing, and Updating data.
✔ Report generation and screen designing.
✔ Programming concepts (Loops, Conditions, Functions).
✔ Handling Numbers & Dates in FoxPro.
✔ Case studies on Inventory Control and Payroll Processing.