Grade 12 : Computer Science Chapter 1 DBMS
1.1 Introduction to data, database, Database system, DBMS 1.2 Field, Record, Objects, Primary Key, Alternate key, Candidate key 1.3 Advantages of using DBMS 1.4 DDL (Data Definition Language) and DML (Data Manipulation Language) 1.5 Database Model: Network Model, Hierarchical Model, Relational database model 1.6 Concept of Normalization: 1NF, 2NF, 3NF 1.7 Centralized Vs. Distributed Database 1.8 Database Security NEB Grade 12 Computer Science (Database Management System) DBMS Chapter 1 Full note
1.1 Introduction to Data, Database, Database System, DBMS
Data
Data is raw facts and figures that have no meaning by themselves. Data can be numbers, text, images, or sounds.
Example:
- John, 15, Attariya, 12th grade
- These are just separate pieces of information with no clear meaning.
Database
A database is an organized collection of related data stored in a computer system. It's like a digital filing cabinet where information is stored in an organized way.
Example:
- A school database containing student names, ages, addresses, grades, and subjects
- A library database with book titles, authors, publication dates, and availability
Database System
A database system is the complete setup that includes the database, the software to manage it, and the hardware it runs on. It's the entire environment needed to store and use data.
Example:
- A hospital's complete computer system with patient records, doctors' schedules, and medicine inventory all connected together
DBMS (Database Management System)
DBMS is special software that helps create, organize, and manage databases. It acts like a controller that handles all database operations.
Example:
- MySQL, Microsoft Access, Oracle
- Like a librarian who organizes books, helps you find them, and keeps track of who borrowed what
1.2 Field, Record, Objects, Primary Key, Alternate Key, Candidate Key
Field
A field is a single piece of information in a database. It's like one column in a table.
Example:
- In a student database: Name, Age, Class, Roll Number are all fields
- Each field stores one type of information
Record
A record is a complete set of related fields about one person or thing. It's like one row in a table.
Example:
- One student's complete information: "Priya Sharma, 16, 10th Grade, Roll No. 25"
- This entire row is one record
Objects
In databases, objects are the things we store information about. They can be people, places, things, or concepts.
Example:
- Students, Teachers, Books, Subjects are all objects
- Each object has different properties (fields) to describe it
Primary Key
A primary key is a field that uniquely identifies each record in a table. No two records can have the same primary key value.
Example:
- Student Roll Number: Each student has a unique roll number
- Employee ID: Each employee gets a unique identification number
- Aadhaar Number: Each person has a unique Aadhaar number
Candidate Key
A candidate key is any field (or combination of fields) that could potentially be used as a primary key. It must be unique for each record.
Example:
- In a student table: Roll Number, Email Address, Phone Number could all be candidate keys
- Each of these can uniquely identify a student
Alternate Key
An alternate key is a candidate key that was not chosen as the primary key. These are backup options for unique identification.
Example:
- If Roll Number is the primary key, then Email Address and Phone Number become alternate keys
- They're still unique but not used as the main identifier
1.3 Advantages of Using DBMS
1. Data Organization
DBMS keeps data well-organized and easy to find, like a well-arranged library.
Example:
- Instead of keeping student records in different files, DBMS stores everything in organized tables that connect to each other
2. Data Sharing
Multiple users can access the same database at the same time safely.
Example:
- In a school, the principal, teachers, and office staff can all access student information simultaneously without conflicts
3. Data Security
DBMS protects data from unauthorized access and accidental loss.
Example:
- Only authorized teachers can view student grades
- Automatic backups prevent data loss if computer crashes
4. Data Consistency
DBMS ensures all data follows the same rules and format.
Example:
- All phone numbers must be 10 digits
- All dates must be in DD/MM/YYYY format
5. Reduced Data Redundancy
DBMS eliminates duplicate information, saving storage space.
Example:
- Instead of storing a student's address in multiple places, it's stored once and referenced everywhere needed
6. Easy Data Retrieval
Finding specific information becomes quick and simple.
Example:
- Searching for all students in 10th grade with marks above 90% takes seconds instead of hours of manual searching
7. Data Integrity
DBMS ensures data remains accurate and reliable.
Example:
- If a student's age is entered as 150, the system will reject it as impossible
- Prevents invalid data from being stored
8. Backup and Recovery
DBMS automatically creates backups and can restore data if something goes wrong.
Example:
- If the school's computer crashes, all student records can be recovered from the backup without losing any information
1.4 DDL (Data Definition Language) and DML (Data Manipulation Language)
DDL (Data Definition Language)
DDL is used to define and modify the structure of database objects like tables, indexes, and schemas.
Common DDL Commands:
- CREATE: Creates new database objects
- ALTER: Modifies existing database structure
- DROP: Deletes database objects
Example:
- CREATE TABLE Students (Name VARCHAR(50), Age INT, Class VARCHAR(10))
- ALTER TABLE Students ADD Email VARCHAR(100)
- DROP TABLE Students
DML (Data Manipulation Language)
DML is used to manipulate data within database objects. It deals with data retrieval, insertion, updating, and deletion.
Common DML Commands:
- SELECT: Retrieves data from database
- INSERT: Adds new data to tables
- UPDATE: Modifies existing data
- DELETE: Removes data from tables
Example:
- SELECT * FROM Students WHERE Class = '10th'
- INSERT INTO Students VALUES ('Rahul', 16, '10th')
- UPDATE Students SET Age = 17 WHERE Name = 'Rahul'
- DELETE FROM Students WHERE Name = 'Rahul'
DCL (Data Control Language)
DCL controls access to data in the database.
- GRANT: Gives user access permissions
- REVOKE: Removes user access permissions
TCL (Transaction Control Language)
TCL manages transactions in the database.
- COMMIT: Saves changes permanently
- ROLLBACK: Undoes changes
1.5 Database Models
Network Model
Data is organized in a network structure where records can have multiple parent and child relationships.
Characteristics:
- Uses pointers to connect related records
- More flexible than hierarchical model
- Complex to implement and maintain
Example:
- A student can be enrolled in multiple courses, and each course can have multiple students
- Like a web where everything is connected to everything else
Hierarchical Model
Data is organized in a tree-like structure with parent-child relationships.
Characteristics:
- Each record has only one parent
- Data flows from top to bottom
- Fast data access but limited flexibility
Example:
- School → Classes → Students
- Company → Departments → Employees
- Like a family tree where each person has only one parent
Relational Database Model
Data is organized in tables (relations) with rows and columns. Most widely used model today.
Characteristics:
- Data stored in tables with rows and columns
- Tables connected through keys
- Easy to understand and use
- Supports SQL language
Example:
- Student table with columns: Roll No, Name, Age, Class
- Course table with columns: Course ID, Course Name, Credits
- Connected through foreign keys
1.6 Concept of Normalization
What is Normalization?
Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity.
1NF (First Normal Form)
A table is in 1NF if:
- All columns contain atomic (single) values
- No repeating groups or arrays
- Each row is unique
Example: Before 1NF:
Student Subjects John Math, Science, English After 1NF:
Student Subject John Math John Science John English 2NF (Second Normal Form)
A table is in 2NF if:
- It's already in 1NF
- All non-key columns are fully dependent on the primary key
Example: Before 2NF:
Student ID Course ID Student Name Course Name 1 101 John Math After 2NF: Split into two tables:
- Students: Student ID, Student Name
- Courses: Course ID, Course Name
3NF (Third Normal Form)
A table is in 3NF if:
- It's already in 2NF
- No transitive dependencies (non-key columns don't depend on other non-key columns)
Example: Before 3NF:
Student ID Course ID Instructor Department 1 101 Dr. Smith Mathematics After 3NF: Split into separate tables to remove dependency between Instructor and Department.
1.7 Centralized Vs. Distributed Database
Centralized Database
All data is stored in one location and managed by a single DBMS.
Advantages:
- Easy to manage and maintain
- Better data consistency
- Lower cost
- Centralized security control
Disadvantages:
- Single point of failure
- Network traffic bottleneck
- Limited scalability
Example:
- Bank's main server storing all customer data
- School's central database for all student records
Distributed Database
Data is stored across multiple locations and connected through a network.
Advantages:
- Better performance and reliability
- No single point of failure
- Improved scalability
- Local data access is faster
Disadvantages:
- Complex to manage
- Higher cost
- Data consistency challenges
- Security concerns
Example:
- ATM network where each branch has local data but connects to central system
- Social media platforms with servers worldwide
1.8 Database Security
What is Database Security?
Database security involves protecting the database from unauthorized access, misuse, and threats.
Security Threats
1. Unauthorized Access
- People accessing data without permission
- Example: Student accessing teacher's grade records
2. Data Theft
- Stealing sensitive information
- Example: Hackers stealing credit card information
3. Data Corruption
- Intentional or accidental data modification
- Example: Virus corrupting database files
4. SQL Injection
- Malicious code inserted through input fields
- Example: Entering harmful code in login forms
Security Measures
1. Authentication
- Verifying user identity through passwords, biometrics
- Example: Username and password login
2. Authorization
- Controlling what authenticated users can do
- Example: Students can view but not modify grades
3. Encryption
- Converting data into coded form
- Example: Credit card numbers stored as encrypted text
4. Backup and Recovery
- Regular data backups for disaster recovery
- Example: Daily automatic backups of school database
5. Access Control
- Limiting database access to authorized users only
- Example: Only librarians can add/remove books from library database
6. Audit Trails
- Recording all database activities for monitoring
- Example: Log showing who accessed which student record when