💾 Introduction to Database | NEB Class 12 Computer Science Notes
Based on Latest Syllabus 2080 | Complete Database Concepts for HSEB Examination
✅ Updated according to latest syllabus of 2080 | Includes all important topics
📚 Introduction — In the modern world, every organization such as schools, hospitals, banks, business houses, government offices, and industries needs to store and manage huge amounts of data. Earlier, organizations used manual record systems and flat file systems, which created many problems such as data duplication, slow processing, and poor security. To overcome these problems, the concept of Database Management System (DBMS) was introduced.
📊 Data and Information
📌 Data
Data are raw facts and figures that are unorganized and do not give clear meaning by themselves. They are collected randomly and need processing to become useful.
Data are raw facts and figures that are unorganized and do not give clear meaning by themselves. They are collected randomly and need processing to become useful.
📌 Information
Information is the processed and organized form of data that gives meaningful results.
Information is the processed and organized form of data that gives meaningful results.
📊 Example of Data
Ram 17 Pokhara 18
These values alone do not provide meaningful understanding. They are just raw, unprocessed facts.
🔍 Characteristics of Data
- Raw and unprocessed
- Unorganized
- Meaningless alone
- Used as input for processing
💡 Example of Information
“Ram is 17 years old and lives in Pokhara.”
This sentence gives proper meaning, so it is information.
✅ Characteristics of Information
- Processed form of data
- Organized and meaningful
- Useful for decision making
- Easy to understand
⚠️ Problems of Traditional File System / Flat File System
Before DBMS, organizations used flat file systems to store records. In this system, data were stored in separate files without proper relationship.
1️⃣ Data Redundancy
Same data were repeated in multiple files.
2️⃣ Data Inconsistency
Repeated data could become different in different files.
3️⃣ Difficult Data Sharing
Sharing data among users was difficult.
4️⃣ Poor Security
Unauthorized users could access data easily.
5️⃣ Slow Data Retrieval
Searching records took a long time.
6️⃣ Difficult Data Processing
Complex operations and queries were difficult.
7️⃣ Lack of Data Integrity
Maintaining accuracy and consistency was difficult.
🗄️ Database
📖 Definition
A database is an organized collection of related data stored systematically so that it can be easily accessed, managed, and updated.
A database stores data in the form of tables consisting of rows and columns.
A database stores data in the form of tables consisting of rows and columns.
📋 Examples of Database
- Telephone directory
- School marks ledger
- Customer records
- Bank records
- Library management system
📋 Example of Database Table
| Roll No | Name | Address | Contact |
|---|---|---|---|
| 1 | Aayush Karki | Pokhara | 0090786 |
| 2 | Bishaka Lohani | Bhairab Tole | 3452423 |
📌 Important Terms
📐 Field (Column)
Definition: A field is a single piece of data or attribute of an entity.
Example: Name, Address, Contact are fields in the above table.
Note: A field represents a column in a database table.
Example: Name, Address, Contact are fields in the above table.
Note: A field represents a column in a database table.
📄 Record (Row)
Definition: A record is a complete set of fields that contains information about one specific entity.
Example: “1, Aayush Karki, Pokhara, 0090786” is one complete record.
Note: A record represents a row in a database table.
Example: “1, Aayush Karki, Pokhara, 0090786” is one complete record.
Note: A record represents a row in a database table.
⚖️ Quick Comparison: Data vs Information
| Basis | Data | Information |
|---|---|---|
| Meaning | Raw facts and figures | Processed meaningful data |
| Organization | Unorganized | Organized |
| Dependency | Independent | Dependent on data |
| Decision Making | Not useful alone | Useful for decisions |
| Example | Ram, 17, Pokhara | “Ram lives in Pokhara” |
📌 Key Points Summary
✓ Database: Organized collection of related data stored in tables.
✓ Field: Individual attribute/column in a table.
✓ Record: Complete row of information about an entity.
✓ Data Redundancy: Duplication of data in multiple files.
✓ Data Inconsistency: Same data having different values in different files.
✓ Flat File System: Traditional file system with multiple limitations.
✓ Field: Individual attribute/column in a table.
✓ Record: Complete row of information about an entity.
✓ Data Redundancy: Duplication of data in multiple files.
✓ Data Inconsistency: Same data having different values in different files.
✓ Flat File System: Traditional file system with multiple limitations.
❓ Frequently Asked Questions (HSEB Pattern)
📌 What is data? Give an example.
Data are raw facts and figures that are unorganized. Example: Ram, 17, Kathmandu.
📌 What is information? Give an example.
Information is processed data that gives meaningful results. Example: “Ram is 17 years old.”
📌 What are the limitations of the flat file system?
- Data redundancy and inconsistency
- Difficult data sharing
- Poor security
- Slow data retrieval
- Difficult complex queries
📌 What is a database? Give examples.
A database is an organized collection of related data stored in tables. Examples: telephone directory, school records, bank records.
📌 Differentiate between field and record.
Field: Column in a table (e.g., Name, Address)
Record: Row in a table (complete information of one entity)
Record: Row in a table (complete information of one entity)
📌 Write any two differences between data and information.
- Data is raw, information is processed
- Data alone is meaningless, information is meaningful
- Data is used as input, information is used for decision making
💾 DBMS (Database Management System) | NEB Class 12 Computer Science Notes
Based on Latest Syllabus 2080 | Complete Database Management Concepts
✅ Updated according to latest syllabus of 2080 | Includes diagrams and detailed explanations
📖 Definition of DBMS
💻 What is DBMS?
DBMS (Database Management System) is software used to create, manage, manipulate, and control databases.
It allows users to:
It allows users to:
- Store data
- Retrieve data
- Update records
- Delete records
- Secure data
📋 Examples of DBMS
Microsoft Access
Oracle Database
MySQL
FoxPro
dBase
PostgreSQL
🎯 Objectives of DBMS
✓ To store large amounts of data systematically
✓ To reduce data redundancy
✓ To ensure data security
✓ To provide fast data retrieval
✓ To maintain data integrity
✓ To allow data sharing
✓ To provide backup and recovery
✅ Advantages of DBMS
1. Data Sharing
Multiple users can access the same database simultaneously.
Example: Branches of a bank share the same customer database.
Multiple users can access the same database simultaneously.
Example: Branches of a bank share the same customer database.
2. Reduces Data Redundancy
Duplicate data are minimized, saving storage space.
Duplicate data are minimized, saving storage space.
3. Data Security
Unauthorized users can be restricted using passwords and user privileges.
Unauthorized users can be restricted using passwords and user privileges.
4. Backup and Recovery
Backup copies can be created and restored during data loss.
Backup copies can be created and restored during data loss.
5. Multiple User Interface
Users can access data from different locations and devices.
Users can access data from different locations and devices.
6. Data Integrity
Accuracy and consistency of data are maintained through constraints.
Accuracy and consistency of data are maintained through constraints.
❌ Disadvantages of DBMS
1. Expensive
DBMS software and hardware cost is high.
DBMS software and hardware cost is high.
2. Requires Skilled Manpower
Technical experts like DBA are needed to manage the system.
Technical experts like DBA are needed to manage the system.
3. Backup Required
Regular backup is necessary to avoid data loss.
Regular backup is necessary to avoid data loss.
4. Complexity
Managing large databases can be difficult and time-consuming.
Managing large databases can be difficult and time-consuming.
📊 Database Models
🗂️ Definition
Database model refers to the logical structure that determines how data are stored, organized, and related.
🌳 1. Hierarchical Database Model
Hierarchical Database Structure (Tree-like)
Root (Parent)
Child 1
Child 2
Child 3
Grandchild 1.1
Grandchild 2.1
Grandchild 3.1
🌲 Features
- Data arranged in tree-like structure
- Follows Parent-Child Relationship
- One parent can have many children
- One child can have only one parent
- Oldest database model (used in IBM IMS)
Advantages: Simple and easy, fast searching, supports one-to-many relationships
Disadvantages: Outdated model, does not support many-to-many relationships, data redundancy exists
🕸️ 2. Network Database Model
Network Database Structure (Graph-like)
Parent A
↔
Child X
↔
Parent B
Many-to-Many Relationship
🔗 Features
- More flexible than hierarchical model
- A child can have multiple parents
- Uses graph structure with pointers
- Developed by CODASYL (Conference on Data Systems Languages)
Advantages: Supports many-to-many relationship, reduces redundancy, faster searching
Disadvantages: Complex design, difficult programming, less structural independence
📋 3. Relational Database Model (RDBMS)
Relational Database Structure (Tabular Form)
| Student_ID | Name | Course |
|---|---|---|
| 101 | Ram | Computer Science |
| 102 | Sita | Mathematics |
| 103 | Hari | Physics |
Data stored in tables (relations) with rows and columns
📊 Features
- Data stored in tables consisting of rows and columns
- Tables are related using keys (Primary Key, Foreign Key)
- Most popular database model today
- Uses SQL (Structured Query Language)
Advantages: Less redundancy, easier database design, faster processing, better security
Disadvantages: Complex relationships, requires powerful hardware
💡 Examples of RDBMS
- MySQL
- Oracle Database
- Microsoft SQL Server
- PostgreSQL
- MariaDB
🌐 Centralized vs Distributed Database System
🏢 Centralized Database System
Centralized Database Architecture
Central Server
↔
Client 1
↔
Client 2
↔
Client N
🏛️ Features
In centralized database system, all data are stored in a single central server. Clients connect directly to the server. Used in small organizations.
Advantages: Easy maintenance, better control, high security
Disadvantages: Single point failure, slow for large organizations, entire network fails if server crashes
🌍 Distributed Database System
Distributed Database Architecture
Server A
↔
Server B
↔
Server C
Multiple servers at different geographical locations
🗺️ Features
Data are distributed across multiple servers located in different geographical locations. Used by large organizations like Google, Facebook, Amazon.
Advantages: Faster access speed, easier backup and recovery, reliable system, handles large number of users
Disadvantages: Expensive, complex maintenance, security issues may arise
⚖️ Difference Between Centralized and Distributed Database
| S.N. | Centralized Database | Distributed Database |
|---|---|---|
| 1 | Simple structure | Complex structure |
| 2 | Single server | Multiple servers |
| 3 | One location | Multiple geographical locations |
| 4 | High security | Comparatively less security |
| 5 | Cheap | Expensive |
| 6 | Easy maintenance | Difficult maintenance |
| 7 | Slow speed for large users | High speed |
| 8 | Entire network fails if server crashes | Failure of one server doesn’t affect whole network |
📌 Key Points Summary
✓ DBMS: Software for creating and managing databases.
✓ Data Redundancy: Duplication of data, reduced by DBMS.
✓ Data Integrity: Accuracy and consistency of data.
✓ Hierarchical Model: Tree structure, parent-child relationship.
✓ Network Model: Graph structure, many-to-many relationships.
✓ Relational Model: Table-based structure, most popular today.
✓ RDBMS: Relational Database Management System (MySQL, Oracle).
✓ Centralized DB: Single server, suitable for small organizations.
✓ Distributed DB: Multiple servers, suitable for large organizations.
✓ Data Redundancy: Duplication of data, reduced by DBMS.
✓ Data Integrity: Accuracy and consistency of data.
✓ Hierarchical Model: Tree structure, parent-child relationship.
✓ Network Model: Graph structure, many-to-many relationships.
✓ Relational Model: Table-based structure, most popular today.
✓ RDBMS: Relational Database Management System (MySQL, Oracle).
✓ Centralized DB: Single server, suitable for small organizations.
✓ Distributed DB: Multiple servers, suitable for large organizations.
❓ Frequently Asked Questions (HSEB Pattern)
📌 What is DBMS? Give examples.
DBMS is software that creates, manages, and controls databases. Examples: MySQL, Oracle, Microsoft Access, FoxPro.
📌 What are the advantages of DBMS?
Data sharing, reduces redundancy, data security, backup and recovery, multiple user interface, data integrity.
📌 What is the difference between hierarchical and network database models?
Hierarchical: tree structure, one child has one parent. Network: graph structure, a child can have multiple parents.
📌 What is RDBMS? Give examples.
RDBMS (Relational Database Management System) stores data in tables with rows and columns. Examples: MySQL, Oracle, PostgreSQL.
📌 Differentiate between centralized and distributed database.
Centralized: single server, one location, simple, cheap. Distributed: multiple servers, different locations, complex, expensive.
🗄️ SQL (Structured Query Language) | NEB Class 12 Computer Science Notes
Based on Latest Syllabus 2080 | Complete SQL Commands with Examples and Results
✅ Updated according to latest syllabus of 2080 | Includes DDL, DML, DCL with practical examples
📖 Definition of SQL
SQL (Structured Query Language) is a standard database language used to communicate with relational databases. It was developed by IBM in the 1970s.
💻 Uses of SQL
- Create tables
- Insert records
- Update data
- Delete data
- Control database access
📚 Types of SQL Languages
1. DDL (Data Definition Language)
🏗️ Definition
DDL defines or modifies the structure of database objects like tables, indexes, and schemas.
CREATE
ALTER
DROP
TRUNCATE
RENAME
📝 CREATE Command Example
CREATE TABLE Student (
SN NUMBER,
Fname TEXT,
Age NUMBER,
City TEXT
);
✅ Result: Table ‘Student’ created successfully.
✏️ ALTER Command Example
ALTER TABLE Student ADD (Email TEXT);
ALTER TABLE Student MODIFY (Fname VARCHAR(50));
✅ Result: Column ‘Email’ added successfully. Column ‘Fname’ modified successfully.
🗑️ DROP Command Example
DROP TABLE Student;
✅ Result: Table ‘Student’ dropped from database.
2. DML (Data Manipulation Language)
🔄 Definition
DML manipulates data inside tables (insert, update, delete, and retrieve records).
INSERT
UPDATE
DELETE
SELECT
📊 Sample Table: Student
| SN | Fname | Age | City |
|---|---|---|---|
| 1 | Ram | 17 | Pokhara |
| 2 | Sita | 16 | Kathmandu |
| 3 | Hari | 18 | Lalitpur |
📝 INSERT Command Example
INSERT INTO Student VALUES (4, ‘Gita’, 17, ‘Biratnagar’);
✅ Result: 1 row inserted successfully.
| SN | Fname | Age | City |
|---|---|---|---|
| 1 | Ram | 17 | Pokhara |
| 2 | Sita | 16 | Kathmandu |
| 3 | Hari | 18 | Lalitpur |
| 4 | Gita | 17 | Biratnagar |
✏️ UPDATE Command Example
UPDATE Student SET Age = 18 WHERE SN = 2;
✅ Result: 1 row updated successfully.
| SN | Fname | Age | City |
|---|---|---|---|
| 1 | Ram | 17 | Pokhara |
| 2 | Sita | 18 | Kathmandu |
| 3 | Hari | 18 | Lalitpur |
| 4 | Gita | 17 | Biratnagar |
🗑️ DELETE Command Example
DELETE FROM Student WHERE SN = 3;
✅ Result: 1 row deleted successfully.
| SN | Fname | Age | City |
|---|---|---|---|
| 1 | Ram | 17 | Pokhara |
| 2 | Sita | 18 | Kathmandu |
| 4 | Gita | 17 | Biratnagar |
🔍 SELECT Command (Retrieve Data)
🔍 SELECT All Records
SELECT * FROM Student;
| SN | Fname | Age | City |
|---|---|---|---|
| 1 | Ram | 17 | Pokhara |
| 2 | Sita | 18 | Kathmandu |
| 4 | Gita | 17 | Biratnagar |
🔍 SELECT Specific Columns
SELECT Fname, City FROM Student;
| Fname | City |
|---|---|
| Ram | Pokhara |
| Sita | Kathmandu |
| Gita | Biratnagar |
🔍 SELECT with WHERE Condition
SELECT * FROM Student WHERE Age >= 18;
| SN | Fname | Age | City |
|---|---|---|---|
| 2 | Sita | 18 | Kathmandu |
🔍 SELECT with ORDER BY
SELECT * FROM Student ORDER BY Fname ASC;
| SN | Fname | Age | City |
|---|---|---|---|
| 4 | Gita | 17 | Biratnagar |
| 1 | Ram | 17 | Pokhara |
| 2 | Sita | 18 | Kathmandu |
3. DCL (Data Control Language)
🔐 Definition
DCL controls access and permissions to the database objects.
GRANT
REVOKE
COMMIT
ROLLBACK
🔑 GRANT Command Example
GRANT SELECT, INSERT ON Student TO user1;
✅ Result: User ‘user1’ granted SELECT and INSERT privileges on Student table.
🚫 REVOKE Command Example
REVOKE INSERT ON Student FROM user1;
✅ Result: INSERT privilege revoked from user ‘user1’.
💾 COMMIT Command Example
COMMIT;
✅ Result: All changes saved permanently to the database.
📋 Complete Practical Example
🏗️ Step 1: Create Database and Table
CREATE DATABASE SchoolDB;
USE SchoolDB;
CREATE TABLE Employees ( EmpID INT PRIMARY KEY, EmpName VARCHAR(50), Salary DECIMAL(10,2), Department VARCHAR(50) );
USE SchoolDB;
CREATE TABLE Employees ( EmpID INT PRIMARY KEY, EmpName VARCHAR(50), Salary DECIMAL(10,2), Department VARCHAR(50) );
✅ Result: Database ‘SchoolDB’ and table ‘Employees’ created.
📝 Step 2: Insert Records
INSERT INTO Employees VALUES (101, ‘Ram Sharma’, 50000, ‘IT’);
INSERT INTO Employees VALUES (102, ‘Sita Gurung’, 55000, ‘HR’);
INSERT INTO Employees VALUES (103, ‘Hari Thapa’, 48000, ‘IT’);
INSERT INTO Employees VALUES (102, ‘Sita Gurung’, 55000, ‘HR’);
INSERT INTO Employees VALUES (103, ‘Hari Thapa’, 48000, ‘IT’);
✅ Result: 3 rows inserted successfully.
| EmpID | EmpName | Salary | Department |
|---|---|---|---|
| 101 | Ram Sharma | 50000 | IT |
| 102 | Sita Gurung | 55000 | HR |
| 103 | Hari Thapa | 48000 | IT |
🔍 Step 3: Retrieve Data with Condition
SELECT * FROM Employees WHERE Department = ‘IT’ AND Salary > 49000;
| EmpID | EmpName | Salary | Department |
|---|---|---|---|
| 101 | Ram Sharma | 50000 | IT |
✏️ Step 4: Update Records
UPDATE Employees SET Salary = Salary * 1.10 WHERE Department = ‘IT’;
✅ Result: 2 rows updated (10% salary increase for IT department).
| EmpID | EmpName | Salary | Department |
|---|---|---|---|
| 101 | Ram Sharma | 55000 | IT |
| 102 | Sita Gurung | 55000 | HR |
| 103 | Hari Thapa | 52800 | IT |
📌 Key Points Summary
📌 SQL Commands Summary Table
| Language | Commands | Purpose |
|---|---|---|
| DDL | CREATE, ALTER, DROP, TRUNCATE, RENAME | Define/Modify database structure |
| DML | INSERT, UPDATE, DELETE, SELECT | Manipulate data in tables |
| DCL | GRANT, REVOKE, COMMIT, ROLLBACK | Control access and permissions |
❓ Frequently Asked Questions (HSEB Pattern)
📌 What is SQL? Write its uses.
SQL (Structured Query Language) is a standard language for managing relational databases. Uses: creating tables, inserting data, updating records, deleting data, and controlling access.
📌 What are the types of SQL commands?
DDL (Data Definition Language), DML (Data Manipulation Language), and DCL (Data Control Language).
📌 Write the difference between DELETE and DROP commands.
DELETE removes rows from a table (DML) and can be rolled back. DROP removes the entire table structure (DDL) and cannot be rolled back.
📌 What is the purpose of SELECT command?
SELECT command is used to retrieve data from one or more tables in a database.
📌 Write the syntax to create a table.
CREATE TABLE table_name (column1 datatype, column2 datatype, …);
📊 ER Model, DBA, Normalization & More | NEB Class 12 Computer Science Notes
Based on Latest Syllabus 2080 | Complete Database Design Concepts
✅ Updated according to latest syllabus of 2080 | Includes pictorial ER diagrams and normalization examples
📐 ER Model (Entity Relationship Model)
📖 Definition
ER Model is a graphical representation of database structure. It shows:
- Entities
- Attributes
- Relationships
🔧 Components of ER Diagram
🎨 ER Diagram Symbols
🔲 Entity
→
⬤ Attribute
→
🔶 Relationship
Symbols: Rectangle = Entity | Oval/Ellipse = Attribute | Diamond = Relationship | Line = Link
🏢 1. Entity
A real-world object that can be identified uniquely.
Example: Student, Teacher, Employee, Product
Symbol: Rectangle
Example: Student, Teacher, Employee, Product
Symbol: Rectangle
📝 2. Attribute
Properties or characteristics of an entity.
Example: Name, Roll Number, Address, Age
Symbol: Oval/Ellipse
Example: Name, Roll Number, Address, Age
Symbol: Oval/Ellipse
🔗 3. Relationship
Association between two or more entities.
Example: “Teacher teaches Student”
Symbol: Diamond
Example: “Teacher teaches Student”
Symbol: Diamond
📏 4. Link
Connects entities, attributes, and relationships.
Symbol: Line
Symbol: Line
📊 Sample ER Diagram: Student and Course
Student
Name
Roll
——
Enrolls in
——
Course
CourseID
Title
ER Diagram showing: Student entity has attributes (Name, Roll). Course entity has attributes (CourseID, Title). Relationship “Enrolls in” connects them.
🔗 Types of Relationships
1. One-to-One (1:1)
One entity relates to exactly one entity.
Example: Person ↔ Passport (one person has one passport)
One entity relates to exactly one entity.
Example: Person ↔ Passport (one person has one passport)
2. One-to-Many (1:M)
One entity relates to many entities.
Example: Department ↔ Employees (one department has many employees)
One entity relates to many entities.
Example: Department ↔ Employees (one department has many employees)
3. Many-to-Many (M:N)
Many entities relate to many entities.
Example: Student ↔ Course (many students take many courses)
Many entities relate to many entities.
Example: Student ↔ Course (many students take many courses)
👨💼 DBA (Database Administrator)
👤 Definition
DBA is the person responsible for managing and controlling the database system. He/she has maximum privileges in the database.
📋 Responsibilities of DBA
✓ Install and maintain database
✓ Provide data security
✓ Create backups and recovery plans
✓ Define user privileges and roles
✓ Train users on database usage
✓ Monitor database performance
✓ Tune database for optimization
⭐ Qualities of a Good DBA
✓ Sound knowledge of DBMS
✓ Knowledge of operating systems
✓ Networking skills
✓ Database design skills
✓ Familiarity with DBMS software (Oracle, MySQL, etc.)
✓ Problem-solving and troubleshooting skills
📏 Normalization
🔄 Definition
Normalization is the process of organizing database tables to reduce redundancy and improve data integrity. It breaks complex tables into smaller related tables.
Introduced by: Edgar F. Codd (1970)
Introduced by: Edgar F. Codd (1970)
✅ Advantages of Normalization
✓ Reduces data redundancy
✓ Improves data consistency
✓ Faster searching and indexing
✓ Easier maintenance
✓ Prevents data loss
📐 Normal Forms
1️⃣ First Normal Form (1NF)
Rules:
- No repeating columns or groups
- Atomic values only (each column has single value)
- Unique rows (primary key identified)
📋 Example: Before 1NF (Repeating Columns)
✅ After 1NF (Atomic Values)
| Student | Subject1 | Subject2 | Subject3 |
|---|---|---|---|
| Ram | Math | Science | English |
| Student | Subject |
|---|---|
| Ram | Math |
| Ram | Science |
| Ram | English |
2️⃣ Second Normal Form (2NF)
Rules:
- Must be in 1NF
- Removes partial dependency (data depending on part of primary key)
3️⃣ Third Normal Form (3NF)
Rules:
- Must be in 2NF
- Removes transitive dependency (non-key attributes depending on other non-key attributes)
🔒 Data Integrity
✅ Definition
Data integrity means maintaining accuracy, consistency, and reliability of data in the database throughout its lifecycle.
📌 Types of Data Integrity
1. Entity Integrity
No duplicate rows; primary key cannot be NULL.
No duplicate rows; primary key cannot be NULL.
2. Referential Integrity
Foreign key must match primary key in another table or be NULL.
Foreign key must match primary key in another table or be NULL.
3. Domain Integrity
Data values must belong to defined domain (data type, range).
Data values must belong to defined domain (data type, range).
🔐 Data Security
🛡️ Definition
Data security means protecting data from unauthorized access, modification, or destruction.
📌 Methods of Data Security
🔑 Password protection
🔒 Data Encryption
👥 User privilege management (GRANT/REVOKE)
💾 Regular Backup
🖥️ Firewall and antivirus
📋 Audit trails
📚 Data Dictionary
📖 Definition
Data dictionary is a collection of metadata (data about data) that contains information about database structure.
📋 What Data Dictionary Stores
✓ Table names
✓ Field/Column names
✓ Data types and lengths
✓ Constraints (Primary Key, Foreign Key)
✓ Indexes and views
✓ User privileges
📋 Sample Data Dictionary for “Student” Table
| Column Name | Data Type | Length | Constraint |
|---|---|---|---|
| SN | NUMBER | 10 | PRIMARY KEY |
| Fname | VARCHAR | 50 | NOT NULL |
| Age | NUMBER | 3 | CHECK (Age >= 0) |
| City | VARCHAR | 50 | – |
⚖️ Difference Between Database and DBMS
| S.N. | Database | DBMS |
|---|---|---|
| 1 | Collection of related data | Software to manage database |
| 2 | Stores data | Manipulates and controls data |
| 3 | Passive (data just exists) | Active (performs operations) |
| 4 | Example: Student records file | Example: MySQL, Oracle, MS Access |
| 5 | Cannot operate alone | Requires database to work |
| 6 | Physical storage of data | Interface between user and database |
📌 Quick Reference Summary
| Term | Definition | Example/Symbol |
|---|---|---|
| Entity | Real-world object | Student, Teacher (Rectangle) |
| Attribute | Property of entity | Name, Roll (Oval) |
| Relationship | Association between entities | Teaches, Enrolls (Diamond) |
| DBA | Database Administrator | Manages database system |
| Normalization | Process to reduce redundancy | 1NF, 2NF, 3NF |
| Data Integrity | Accuracy and consistency of data | Entity, Referential, Domain |
| Data Security | Protection from unauthorized access | Password, Encryption, Privileges |
| Data Dictionary | Metadata repository | Table definitions, constraints |
❓ Frequently Asked Questions (HSEB Pattern)
📌 What is ER Model? Draw its components.
ER Model is a graphical representation of database structure. Components: Entity (Rectangle), Attribute (Oval), Relationship (Diamond), Link (Line).
📌 What are the responsibilities of DBA?
Install/maintain database, provide security, create backups, define user privileges, train users, monitor performance.
📌 What is normalization? Explain 1NF, 2NF, 3NF.
Normalization organizes tables to reduce redundancy. 1NF: no repeating columns. 2NF: removes partial dependency. 3NF: removes transitive dependency.
📌 Differentiate between database and DBMS.
Database stores data; DBMS is software to manage database. Database is passive, DBMS is active.
📌 What is data integrity? List its types.
Data integrity ensures accuracy and consistency. Types: Entity Integrity, Referential Integrity, Domain Integrity.
📚 Frequently Asked Examination Questions | NEB Class 12 Computer Science
Based on Latest Syllabus 2080 | Complete Answers for HSEB Examination
Important Questions for Board Exam
Define DBMS and explain its objectives.
Definition of DBMS:
DBMS (Database Management System) is software that creates, manages, manipulates, and controls databases. It allows users to store, retrieve, update, delete, and secure data.
Examples: MySQL, Oracle, Microsoft Access, FoxPro, dBase.
Objectives of DBMS:
DBMS (Database Management System) is software that creates, manages, manipulates, and controls databases. It allows users to store, retrieve, update, delete, and secure data.
Examples: MySQL, Oracle, Microsoft Access, FoxPro, dBase.
Objectives of DBMS:
- To store large amounts of data systematically – Organizes data in structured tables.
- To reduce data redundancy – Minimizes duplicate data across files.
- To ensure data security – Restricts unauthorized access using passwords and privileges.
- To provide fast data retrieval – Uses indexing and query optimization.
- To maintain data integrity – Ensures accuracy and consistency using constraints.
- To allow data sharing – Multiple users can access the same database simultaneously.
- To provide backup and recovery – Creates copies of data for disaster recovery.
Explain relational database model with advantages.
Relational Database Model (RDBMS):
In the relational database model, data are organized into tables consisting of rows and columns. These tables are called relations. Tables are related using keys (Primary Key, Foreign Key). It is the most popular database model today.
Examples: MySQL, Oracle Database, Microsoft SQL Server, PostgreSQL.
Structure:
Advantages of Relational Database Model:
In the relational database model, data are organized into tables consisting of rows and columns. These tables are called relations. Tables are related using keys (Primary Key, Foreign Key). It is the most popular database model today.
Examples: MySQL, Oracle Database, Microsoft SQL Server, PostgreSQL.
Structure:
| Roll No | Name | Course |
|---|---|---|
| 1 | Ram | CS |
| 2 | Sita | Math |
- Less data redundancy: Duplicate data minimized through normalization.
- Easier database design: Simple table structure is easy to understand.
- Faster processing: Optimized queries using SQL.
- Better security: User privileges can be granted at table or column level.
- Data independence: Changes in physical storage don’t affect logical structure.
- Flexibility: Supports complex queries and joins between tables.
Differentiate between DBMS and RDBMS.
| S.N. | DBMS | RDBMS |
|---|---|---|
| 1 | Stores data in files or flat structures | Stores data in tables with rows and columns |
| 2 | Does not support relationships between tables | Supports relationships using foreign keys |
| 3 | No support for normalization | Supports normalization to reduce redundancy |
| 4 | Does not enforce integrity constraints | Enforces entity, referential, and domain integrity |
| 5 | Examples: FoxPro, dBase, MS Access (file-based) | Examples: MySQL, Oracle, PostgreSQL, SQL Server |
| 6 | Suitable for small applications | Suitable for large enterprise applications |
Explain centralized and distributed database systems.
Centralized Database System:
All data are stored in a single central server. Clients connect directly to this server. Used in small organizations.
Advantages: Easy maintenance, better control, high security.
Disadvantages: Single point of failure, slow for large users, entire network fails if server crashes.
Distributed Database System:
Data are distributed across multiple servers located in different geographical locations. Used by large organizations like Google, Facebook.
Advantages: Faster access speed, easier backup and recovery, reliable, handles large number of users.
Disadvantages: Expensive, complex maintenance, security issues may arise.
Comparison Table:
All data are stored in a single central server. Clients connect directly to this server. Used in small organizations.
Advantages: Easy maintenance, better control, high security.
Disadvantages: Single point of failure, slow for large users, entire network fails if server crashes.
Distributed Database System:
Data are distributed across multiple servers located in different geographical locations. Used by large organizations like Google, Facebook.
Advantages: Faster access speed, easier backup and recovery, reliable, handles large number of users.
Disadvantages: Expensive, complex maintenance, security issues may arise.
Comparison Table:
| Centralized DB | Distributed DB |
|---|---|
| Single server | Multiple servers |
| One location | Multiple geographical locations |
| Simple structure | Complex structure |
| Cheap | Expensive |
| Easy maintenance | Difficult maintenance |
| Slow for large users | High speed |
Explain hierarchical database model with advantages and disadvantages.
Hierarchical Database Model:
In this model, data are arranged in a tree-like structure. It follows Parent-Child Relationship where one parent can have many children, but one child can have only one parent. It is the oldest database model (used in IBM IMS).
Example Structure:
Advantages:
In this model, data are arranged in a tree-like structure. It follows Parent-Child Relationship where one parent can have many children, but one child can have only one parent. It is the oldest database model (used in IBM IMS).
Example Structure:
Root (Department) → Child (Employee) → Grandchild (Project)Advantages:
- Simple and easy to understand
- Fast searching and retrieval if parent is known
- Supports one-to-one and one-to-many relationships
- Outdated model, not used in modern systems
- Does not support many-to-many relationships
- Data redundancy exists because data may be repeated
- Adding new relationships is complex
What is normalization? Explain 1NF, 2NF, and 3NF with examples.
Definition of Normalization:
Normalization is the process of organizing database tables to reduce redundancy and improve data integrity. It breaks complex tables into smaller related tables. Introduced by Edgar F. Codd in 1970.
1NF (First Normal Form):
After 1NF: (Ram, Math), (Ram, Science), (Ram, English) – each subject in separate row.
2NF (Second Normal Form):
3NF (Third Normal Form):
Advantages of Normalization: Reduces redundancy, improves consistency, faster searching, easier maintenance.
Normalization is the process of organizing database tables to reduce redundancy and improve data integrity. It breaks complex tables into smaller related tables. Introduced by Edgar F. Codd in 1970.
1NF (First Normal Form):
- No repeating columns or groups
- Atomic values only (each column has single value)
- Unique rows identified by primary key
After 1NF: (Ram, Math), (Ram, Science), (Ram, English) – each subject in separate row.
2NF (Second Normal Form):
- Must be in 1NF
- Removes partial dependency (data depending on part of composite primary key)
3NF (Third Normal Form):
- Must be in 2NF
- Removes transitive dependency (non-key attributes depending on other non-key attributes)
Advantages of Normalization: Reduces redundancy, improves consistency, faster searching, easier maintenance.
Define DBA and explain responsibilities of DBA.
Definition of DBA (Database Administrator):
DBA is the person responsible for managing and controlling the database system. He/she has maximum privileges in the database.
Responsibilities of DBA:
DBA is the person responsible for managing and controlling the database system. He/she has maximum privileges in the database.
Responsibilities of DBA:
- Install and maintain database: Installs DBMS software and keeps it updated.
- Provide data security: Protects data from unauthorized access.
- Create backups and recovery: Performs regular backups and restores data when needed.
- Define user privileges: Grants different access levels to different users.
- Train users: Educates users on how to use the database system.
- Monitor database performance: Tunes queries and optimizes performance.
- Manage storage: Allocates storage space and manages data growth.
- Sound knowledge of DBMS
- Knowledge of operating systems
- Networking skills
- Database design skills
- Familiarity with DBMS software (Oracle, MySQL, etc.)
Write short notes on:
ERD (Entity Relationship Diagram)
ERD is a graphical representation of database structure. It shows:
• Entities (Rectangle) – Real-world objects like Student, Teacher
• Attributes (Oval) – Properties like Name, Roll
• Relationships (Diamond) – Associations like “Enrolls in”
• Links (Line) – Connections between components
Used for database design and showing relationships.
ERD is a graphical representation of database structure. It shows:
• Entities (Rectangle) – Real-world objects like Student, Teacher
• Attributes (Oval) – Properties like Name, Roll
• Relationships (Diamond) – Associations like “Enrolls in”
• Links (Line) – Connections between components
Used for database design and showing relationships.
SQL (Structured Query Language)
SQL is a standard language for managing relational databases. Developed by IBM in 1970s.
Types:
• DDL: CREATE, ALTER, DROP – defines structure
• DML: INSERT, UPDATE, DELETE, SELECT – manipulates data
• DCL: GRANT, REVOKE – controls access
Example:
SQL is a standard language for managing relational databases. Developed by IBM in 1970s.
Types:
• DDL: CREATE, ALTER, DROP – defines structure
• DML: INSERT, UPDATE, DELETE, SELECT – manipulates data
• DCL: GRANT, REVOKE – controls access
Example:
SELECT * FROM Student WHERE Age > 18;
Data Integrity
Data integrity means maintaining accuracy, consistency, and reliability of data.
Types:
• Entity Integrity: No duplicate rows; primary key cannot be NULL
• Referential Integrity: Foreign key must match primary key in another table
• Domain Integrity: Data must belong to defined domain (data type, range)
Enforced using constraints like PRIMARY KEY, FOREIGN KEY, CHECK.
Data integrity means maintaining accuracy, consistency, and reliability of data.
Types:
• Entity Integrity: No duplicate rows; primary key cannot be NULL
• Referential Integrity: Foreign key must match primary key in another table
• Domain Integrity: Data must belong to defined domain (data type, range)
Enforced using constraints like PRIMARY KEY, FOREIGN KEY, CHECK.
Data Security
Data security means protecting data from unauthorized access, modification, or destruction.
Methods:
• Password protection
• Data Encryption
• User privilege management (GRANT/REVOKE)
• Regular Backup
• Firewall and antivirus
• Audit trails to track access
Data security means protecting data from unauthorized access, modification, or destruction.
Methods:
• Password protection
• Data Encryption
• User privilege management (GRANT/REVOKE)
• Regular Backup
• Firewall and antivirus
• Audit trails to track access
Data Dictionary
Data dictionary is a collection of metadata (data about data) that contains information about database structure.
Stores:
• Table names
• Column/Field names
• Data types and lengths
• Constraints (Primary Key, Foreign Key)
• Indexes and views
• User privileges
Example: System tables in Oracle (USER_TABLES, USER_TAB_COLUMNS)
Data dictionary is a collection of metadata (data about data) that contains information about database structure.
Stores:
• Table names
• Column/Field names
• Data types and lengths
• Constraints (Primary Key, Foreign Key)
• Indexes and views
• User privileges
Example: System tables in Oracle (USER_TABLES, USER_TAB_COLUMNS)
Additional Important Short Notes
Data vs Information
Data: Raw, unorganized facts (e.g., Ram, 17, Pokhara)
Information: Processed, meaningful data (e.g., “Ram is 17 years old from Pokhara”)
Data: Raw, unorganized facts (e.g., Ram, 17, Pokhara)
Information: Processed, meaningful data (e.g., “Ram is 17 years old from Pokhara”)
Primary Key vs Foreign Key
Primary Key: Uniquely identifies each row; cannot be NULL.
Foreign Key: References primary key of another table; can be NULL.
Primary Key: Uniquely identifies each row; cannot be NULL.
Foreign Key: References primary key of another table; can be NULL.
1NF, 2NF, 3NF Summary
• 1NF: No repeating columns, atomic values
• 2NF: 1NF + no partial dependency
• 3NF: 2NF + no transitive dependency
• 1NF: No repeating columns, atomic values
• 2NF: 1NF + no partial dependency
• 3NF: 2NF + no transitive dependency
Examination Tips
- For DBMS questions: Always mention examples (MySQL, Oracle) and list objectives clearly.
- For comparison questions: Use table format for better presentation and marks.
- For normalization: Always provide examples to explain 1NF, 2NF, 3NF.
- For short notes: Write at least 5-6 key points with heading and bullet points.
- For ERD: Remember symbols: Rectangle=Entity, Oval=Attribute, Diamond=Relationship.
- Draw diagrams wherever possible: ER diagrams, tree structures, tables fetch more marks.