Introduction to Database
Data
● Raw, unprocessed facts and figures.
● Can be numbers, text, images, symbols, or observations.
● Has no meaning on its own until it is interpreted.
● Example: "98", "Blue", "2025", "John"
Information
● Processed, organized, or structured data.
● Provides context and meaning.
● Helps in decision-making and communication.
● Example: "John scored 98 in the 2025 math exam."
What is a Database?
● A database is an organized collection of data.
● It stores information in a structured way.
● Allows easy access, management, and updating of data.
● Example: School database storing students’ details.
Need for a Database
● To manage large amounts of data efficiently.
● To avoid data redundancy (repetition).
● To ensure data consistency.
● For quick retrieval and processing of information.
● To maintain data security and integrity.
What is DBMS (Database Management System)?
● Software used to create, manage, and manipulate databases.
● Provides an interface between the user and the data.
● Examples: MySQL, Oracle, PostgreSQL, MS Access.
Advantages of DBMS
● Reduces data redundancy.
● Ensures data consistency.
● Improves data sharing.
● Enhances data security.
● Provides backup and recovery options.
Database Terminologies
● Table: Collection of related data in rows and columns.
● Record (Row): A single entry of data.
● Field (Column): A data attribute (e.g., Name, Age).
● Primary Key: Unique identifier for each record.
● Foreign Key: Links tables together.
Primary Key
Definition:
A Primary Key is a field (or combination of fields) in a table that uniquely identifies each record in that table.
It cannot have duplicate or NULL values.
Example:
In a table STUDENT(RollNo, Name, Class, Marks)
A Candidate Key is any field or set of fields that can uniquely identify each record in a table.
Every table can have multiple candidate keys, but only one is chosen as the primary key.
Example:
In a table EMPLOYEE(EmpID, AadharNo, Name, Department)
● Both EmpID and AadharNo can uniquely identify employees.
● So both are Candidate Keys.
● If EmpID is chosen as Primary Key, then AadharNo becomes an Alternate Key.
An Alternate Key is a Candidate Key that is not selected as the Primary Key.
It can still uniquely identify records, but it’s not used as the main identifier.
Example:
From the above EMPLOYEE table:
● Candidate Keys: EmpID, AadharNo
● Primary Key: EmpID
● Alternate Key: AadharNo
A Foreign Key is a field in one table that links to the Primary Key of another table.
It is used to maintain referential integrity between two related tables.
Flat File Database Relational Database
Stores data in a single table or file, usually in plain text or Stores data in multiple related tables using keys.
spreadsheet format.
Simple structure — rows and columns in one table. Complex structure — multiple tables linked by relationships.
High redundancy (data may be repeated). Low redundancy (data is normalized and stored once).
Difficult to maintain consistency. Easy to maintain consistency using relationships and constraints.
Data Integrity** Not enforced. Enforced through Primary and Foreign Keys.
Cannot represent relationships between data. Can represent one-to-one, one-to-many, or many-to-many
relationships.
Limited security features. Strong security controls and user access management.
CSV files, Excel sheets, simple text files. MySQL, Oracle, PostgreSQL, MS Access.
Types of Databases
● Relational Database (e.g., MySQL, Oracle)
● Hierarchical Database
● Network Database
COMPANY
|
---------------------
| | |
HR Dept IT Dept Sales Dept
| |
Employees Employees
Student1 ─┬─ CourseA
├─ CourseB
Student2 ──┘
Referential Integrity is a rule that maintains consistency between related tables in a database.
It ensures that a Foreign Key value in one table must always refer to an existing Primary Key value in another table.
Why Referential Integrity is Necessary
● ✅ Prevents invalid or orphan records in child tables.
● ✅ Ensures data consistency and accuracy across tables.
● ✅ Maintains logical relationships between tables.
● ✅ Helps enforce data reliability and error-free transactions.
Type of Relationship
One-to-One (1:1)
One record in Table A is related to only one record in Table B.
Each student has one ID card.STUDENT ↔ ID_CARD
One-to-Many (1:M)
One record in Table A can be related to many records in Table B.
One teacher teaches many students.TEACHER → STUDENT
Many-to-Many (M:N)
Many records in Table A relate to many records in Table B.
Many students can enroll in many courses.STUDENT ↔ COURSE (through ENROLL table)
A query is a question or command that retrieves specific information from a database.
It allows users to search, filter, update, or analyze data stored in tables.
DDL
Data Definition Language
Defines database structure
CREATE, ALTER, DROP
DML
Data Manipulation Language
Manipulates data
INSERT, UPDATE, DELETE
DQL
Data Query Language
Retrieves data
SELECT
DCL
Data Control Language
Controls access
GRANT, REVOKE
TCL
Transaction Control Language
Manages transactions
COMMIT, ROLLBACK, SAVEPOINT
A Form is a user-friendly interface in a database that allows users to enter, view, and edit data easily
without directly working with tables.
It displays data one record at a time and often includes text boxes, drop-down lists, and buttons.
Uses of Forms:
● ✅ To enter new data into a table.
● ✅ To view or update existing records.
● ✅ To prevent data entry errors by using controls (like dropdowns).
● ✅ To make data entry simple and user-friendly, even for non-technical users.
● ✅ To customize layout and design for better readability.
A Report is a formatted and organized output of data from one or more tables or queries, designed for
printing or presentation purposes.
It is used to summarize and analyze database information in a readable layout.
Uses of Reports:
● ✅ To present data in an organized and attractive format.
● ✅ To summarize large amounts of data (e.g., total sales, average marks).
● ✅ To print hard copies of database information.
● ✅ To share insights or results with others.
● ✅ To create summary or analytical reports (like monthly sales or student performance).