CHAPTER PDF
Complete curriculum textbook chapter document for reading and offline study.
NOTES
Complete conceptual breakdown, formulas, diagrams, and memory aids.
Database Concepts
Complete chapter notes covering file systems, DBMS, relational databases, relation properties and database keys—with clear explanations, examples, practical SQL illustrations and solved textbook exercises.
1. Introduction to Database Concepts
Data is an important resource. After collecting data, it must be stored, organised, updated and retrieved whenever required. A computerised system helps manage a large volume of information more efficiently than manual registers.
School attendance example
Imagine a school with 50 students and 26 working days in a month. The class teacher must record attendance for every student on every working day.
50 students × 26 working days = 1,300 entries.
The office also maintains student details—Roll Number, Name and Date of Birth—and guardian details—Guardian Name, Contact Number and Address.
Problems with manual record keeping
- Student details must be entered again when a student is promoted to the next class.
- Repeated writing can cause spelling mistakes, skipped records and inconsistent information.
- Registers may be lost or damaged, resulting in data loss.
- Manual calculation while preparing attendance summaries may be incorrect.
- Searching, modifying or deleting a record in a large collection of paper registers is difficult.
What should a computerised system allow?
- Copy student details to a new class attendance file.
- Search student or guardian information.
- Add details when a new student joins.
- Modify student or guardian details when they change.
- Delete records when a student leaves, subject to the organisation's record-retention rules.
2. File System
A file is a container used to store data in a computer. Files are stored on storage devices. A file may contain text, program code, comma-separated values (CSV), pictures, audio, video or web-page content.
Files can be opened directly, but when software must retrieve particular information from a file—for example, display a monthly attendance report—the developer generally needs to write an application program to read and process that file.
School example: two separate files
The school may maintain a STUDENT file for personal details and an ATTENDANCE file for daily attendance.
STUDENT file – fields and meaning
| Field | Meaning | Example value |
|---|---|---|
| RollNumber | Student's roll number | 1 |
| SName | Student's name | Atharv Ahuja |
| SDateofBirth | Student's date of birth | 2003-05-15 |
| GName | Guardian's name | Amit Ahuja |
| GPhone | Guardian's phone number | 5711492685 |
| GAddress | Guardian's address | G-35, Ashok Vihar, Delhi |
ATTENDANCE file – fields and meaning
| Field | Meaning | Example value |
|---|---|---|
| AttendanceDate | Date on which attendance is marked | 2018-09-01 |
| RollNumber | Roll number of the student | 1 |
| SName | Name of the student | Atharv Ahuja |
| AttendanceStatus | P = Present, A = Absent | P |
Sample attendance records:
| AttendanceDate | RollNumber | SName | AttendanceStatus |
|---|---|---|---|
| 2018-09-01 | 1 | Atharv Ahuja | P |
| 2018-09-01 | 2 | Daizy Bhutia | P |
| 2018-09-01 | 3 | Taleem Shah | A |
| 2018-09-02 | 1 | Atharv Ahuja | P |
| 2018-09-02 | 4 | John Dsouza | A |
3. Limitations of a File System
A file system becomes difficult to manage when the number of files and the volume of data increase. The chapter explains six major limitations.
3.1 Difficulty in Access
Files do not themselves provide a flexible mechanism for retrieving information in every required format. Data is accessed through application programs. If the developer did not anticipate a particular retrieval requirement, a new program may have to be written.
3.2 Data Redundancy
Data redundancy means storing the same data more than once in different places or files. In the school example, student names are stored in both STUDENT and ATTENDANCE files. Guardian information may also be repeated for siblings.
- Uses extra storage space.
- Creates repeated work during data entry and updates.
- May lead to data inconsistency.
3.3 Data Inconsistency
Data inconsistency occurs when the same data stored at different places does not match.
3.4 Data Isolation
Related data may be stored in separate files without a proper link or mapping. Different files may also have different formats and structures. It becomes difficult to combine information from them because the application must understand each file's structure.
3.5 Data Dependence
Data in a file is stored in a particular structure or format. If that structure changes, the application programs that use the file may also need modification. This dependence of programs on the file structure is called data dependence.
3.6 Controlled Data Sharing
Different users should have different permissions. A teacher may be allowed to update attendance, while guardians and office staff may only be allowed to view it. Enforcing such role-based access restrictions is difficult when files are accessed through separate application programs.
| Limitation | Meaning in one line |
|---|---|
| Difficulty in Access | Retrieving data in a required format may need a specially written program. |
| Data Redundancy | Same data is duplicated in multiple places. |
| Data Inconsistency | Copies of the same data do not match. |
| Data Isolation | Related data is separated and difficult to combine. |
| Data Dependence | Changing file structure may require changing application programs. |
| Controlled Data Sharing | Giving different users appropriate access rights is difficult. |
4. Database Management System (DBMS)
A database stores logically related data in an organised manner. A Database Management System (DBMS) is software used to create and manage databases.
A DBMS allows users or application programs to create a database, store data, retrieve data, and insert, update or delete records. It acts as an interface between the database and its users or application programs.
Examples of DBMS
- MySQL – widely used relational database management system.
- Oracle Database – commercial database management system.
- PostgreSQL – open-source relational database management system.
- Microsoft SQL Server – commercial relational database management system.
- Microsoft Access – database management software.
- MongoDB – document-oriented database system.
Some DBMS products provide a graphical user interface (GUI). Others can be managed through a command-line interface (CLI), where users enter commands.
Querying a database
Retrieving information from a database by giving a request is called querying the database. A query can retrieve data or request a change to stored data.
Real-life applications of databases
| Application | Examples of data maintained |
|---|---|
| Banking | Customer information, account details, loan details and transaction details. |
| Crop loan | Kisan Credit Card data, farmer details, land area, cultivation, loan history and repayments. |
| Inventory management | Product details, customer information, orders and delivery data. |
| Organisation Resource Management | Employee records, salary details, departments and branch locations. |
| Online shopping | Item descriptions, user login details and user preferences. |
Advantages of using a DBMS in the school example
- Related information can be organised in tables.
- Repeated data can be reduced by separating student, guardian and attendance information.
- Data can be searched and retrieved through queries.
- Multiple authorised users can work with a central database.
- Data can be inserted, updated and deleted in a controlled manner.
Limitations of DBMS
- Increased complexity: Managing security, consistency, sharing and integrity adds complexity.
- Increased data vulnerability: Centralised data may be affected by hardware or software failure. A failure can interrupt operations for many users. Regular backup and recovery planning are therefore important.
5. File System to DBMS – School Database Example
Suppose the school initially maintains STUDENT and ATTENDANCE files. To design a database, related tables are connected through common fields. The original files can be reorganised to reduce duplication and represent relationships clearly.
Changes required
- Remove repeated student name from ATTENDANCE. SName is already stored in STUDENT. The student name can be obtained using the common RollNumber field.
- Separate guardian details. If siblings share the same guardian, storing guardian details in every student record duplicates information. Create a separate GUARDIAN table.
- Introduce GUID (Guardian ID). Guardian names may not be unique. A unique GUID identifies each guardian. Store GUID in GUARDIAN and in STUDENT to connect the records.
Resulting table structures
| Table | Fields | Purpose |
|---|---|---|
| STUDENT | RollNumber, SName, SDateofBirth, GUID | Stores each student's details and the related guardian ID. |
| GUARDIAN | GUID, GName, GPhone, GAddress | Stores each guardian's details once. |
| ATTENDANCE | AttendanceDate, RollNumber, AttendanceStatus | Stores the attendance status of a student on a date. |
Sample STUDENT table
| RollNumber | SName | SDateofBirth | GUID |
|---|---|---|---|
| 1 | Atharv Ahuja | 2003-05-15 | 444444444444 |
| 2 | Daizy Bhutia | 2002-02-28 | 111111111111 |
| 3 | Taleem Shah | 2002-02-28 | 101010101010 |
| 4 | John Dsouza | 2003-08-18 | 333333333333 |
| 5 | Ali Shah | 2003-07-05 | 101010101010 |
| 6 | Manika P. | 2002-03-10 | 466444444666 |
Sample GUARDIAN table
| GUID | GName | GPhone | GAddress |
|---|---|---|---|
| 444444444444 | Amit Ahuja | 5711492685 | G-35, Ashok Vihar, Delhi |
| 111111111111 | Baichung Bhutia | 3612967082 | Flat no. 5, Darjeeling Appt., Shimla |
| 101010101010 | Himanshu Shah | 4726309212 | 26/77, West Patel Nagar, Ahmedabad |
| 333333333333 | Danny Dsouza | NULL | S-13, Ashok Village, Daman |
| 466444444666 | Sujata P. | 3801923168 | HNO-13, B-block, Preet Vihar, Madurai |
Sample ATTENDANCE table
| AttendanceDate | RollNumber | AttendanceStatus |
|---|---|---|
| 2018-09-01 | 1 | P |
| 2018-09-01 | 2 | P |
| 2018-09-01 | 3 | A |
| 2018-09-02 | 1 | P |
| 2018-09-02 | 4 | A |
GUID (unique)
GUID refers to guardian
RollNumber refers to student
One guardian may be associated with multiple students. One student may have multiple attendance records on different dates.
The database can be stored in a central location and accessed by multiple authorised users, such as teachers and office staff, at the same time.
6. Key Concepts in DBMS
6.1 Database Schema
A database schema is the design or structural description of a database. It describes table names, fields/columns, data types, constraints and relationships among tables. It is the skeleton or logical architecture of the database.
STUDENT(RollNumber, SName, SDateofBirth, GUID)
GUARDIAN(GUID, GName, GPhone, GAddress)
6.2 Data Constraint
A data constraint is a restriction placed on the values that may be entered into one or more columns. Constraints help maintain accuracy and reliability.
Examples:
- RollNumber must not be empty.
- RollNumber must be unique for every student.
- A mobile number may be restricted to non-negative integer values of exactly ten digits, as in the textbook illustration.
6.3 Metadata or Data Dictionary
Metadata means data about data. The DBMS stores the database schema and its constraints in a database catalog or data dictionary. It describes the structure and rules of the stored data rather than being ordinary business records.
6.4 Database Instance (Database State)
A database schema initially defines an empty structure. After records are inserted, the contents of the database at a particular time are called the database instance or database state. The instance changes when records are inserted, updated or deleted. One schema can have many instances over time.
6.5 Query
A query is a request made to a database to obtain information in a desired way. A query may retrieve data from one table or combine information from multiple related tables. Query languages such as SQL are used to communicate with relational databases.
6.6 Data Manipulation
Modification of database contents involves three basic operations:
- Insertion: Adding a new record. Example: add a newly admitted student.
- Deletion: Removing a record. Example: remove a student's record when permitted by the school's policy.
- Update: Changing an existing value. Example: update a guardian's phone number.
6.7 Database Engine
The database engine is the underlying component or set of programs used by a DBMS to create databases and handle queries for data retrieval and manipulation.
| Term | Meaning | Easy way to remember |
|---|---|---|
| Schema | Database design/structure | Blueprint |
| Constraint | Rule restricting data values | Validation rule |
| Metadata | Data describing the database structure | Data about data |
| Instance | Database contents at a particular time | Current snapshot |
| Query | Request for database information or action | Question/request |
| Data manipulation | Insert, delete or update records | Change data |
| Database engine | Core component that processes database operations | Processing core |
7. Relational Data Model
A data model describes how data is structured and represented, how data items are related, and what constraints apply. The chapter mentions relational, object-oriented, entity-relationship, document and hierarchical data models.
In the relational data model, data is stored in tables. A table is called a relation. Each table contains columns and rows. Every column has a unique name, and each row represents a set of related values.
Relations are connected
Tables in a relational database are not isolated. Common fields and keys connect related records. In the school database:
- ATTENDANCE.RollNumber refers to the matching student in STUDENT.
- STUDENT.GUID refers to the matching guardian in GUARDIAN.
Without appropriate linking attributes, the DBMS cannot reliably connect the records to retrieve valid information.
Relation schemas in StudentAttendance
| Relation schema | Attribute description |
|---|---|
| STUDENT(RollNumber, SName, SDateofBirth, GUID) | RollNumber: student identifier; SName: student name; SDateofBirth: date of birth; GUID: guardian identifier. |
| ATTENDANCE(AttendanceDate, RollNumber, AttendanceStatus) | AttendanceDate: date of attendance; RollNumber: student identifier; AttendanceStatus: P or A. The combination of date and roll number is unique. |
| GUARDIAN(GUID, GName, GPhone, GAddress) | GUID: guardian identifier; GName: guardian name; GPhone: contact number; GAddress: address. |
8. Relational Data Model Terminology
Consider the following GUARDIAN relation:
| GUID | GName | GPhone | GAddress |
|---|---|---|---|
| 444444444444 | Amit Ahuja | 5711492685 | G-35, Ashok Vihar, Delhi |
| 111111111111 | Baichung Bhutia | 3612967082 | Darjeeling Apartment, Shimla |
| 101010101010 | Himanshu Shah | 4726309212 | West Patel Nagar, Ahmedabad |
| 333333333333 | Danny Dsouza | NULL | Ashok Village, Daman |
| 466444444666 | Sujata P. | 3801923168 | Preet Vihar, Madurai |
8.1 Attribute
An attribute is a characteristic or parameter for which data is stored in a relation. It is a column or field in a table.
Example: GUID, GName, GPhone and GAddress are the four attributes of GUARDIAN.
8.2 Tuple
A tuple is a row in a relation. It contains related values for all the attributes of that record.
Example: The row containing GUID 444444444444, Amit Ahuja, 5711492685 and the Delhi address is one tuple.
8.3 Domain
A domain is the set of permitted values from which an attribute can take a value. A data type commonly specifies the domain.
- RollNumber may have an integer domain.
- SName may have a character-string domain.
- AttendanceStatus may be restricted to P or A by an appropriate rule.
8.4 Degree
Degree is the number of attributes (columns) in a relation.
GUARDIAN has four attributes—GUID, GName, GPhone and GAddress. Therefore, its degree is 4.
8.5 Cardinality
Cardinality is the number of tuples (rows/records) in a relation.
The sample GUARDIAN relation has five rows. Therefore, its cardinality is 5.
| Term | Database part | Example in GUARDIAN | Count |
|---|---|---|---|
| Attribute | Column | GUID, GName, GPhone, GAddress | 4 attributes |
| Tuple | Row | One guardian's complete record | One tuple per row |
| Domain | Allowed values for an attribute | Character strings for GName | Set of permitted values |
| Degree | Number of columns | 4 | 4 |
| Cardinality | Number of rows | 5 | 5 |
9. Three Important Properties of a Relation
Property 1 – Rules about attributes (columns)
- Each attribute in a relation must have a unique name.
- The sequence/order of attributes is immaterial. Rearranging columns does not change the logical relation if their names and values remain correctly associated.
Property 2 – Rules about tuples (rows)
- Each tuple must be distinct. No two tuples may have identical values for all attributes.
- The sequence/order of tuples is immaterial. Sorting rows differently does not change the relation's logical contents.
Property 3 – Rules about the state of a relation
- Same domain in a column: All values in an attribute must belong to the same domain/data type.
- Atomic values: Each value should be indivisible into meaningful subparts for the purpose of the relation. For example, the textbook treats a ten-digit phone number as one atomic value.
- No multivalued cell: An attribute should not contain multiple values in one tuple. For example, do not store several guardian phone numbers together in one GPhone cell.
- NULL: NULL represents a value that is unknown or not applicable. For example, GPhone may be NULL if the guardian has not provided a phone number.
Appropriate: GPhone = 9876543210
Not appropriate for a single-valued GPhone field: GPhone = 9876543210, 9123456780
Understanding NULL
NULL is not the same as zero, a blank string, or the word “NULL” typed as ordinary text. It indicates that a value is unknown, unavailable or not applicable. A NULL value does not mean that the value is zero.
10. Keys in a Relational Database
Every tuple in a relation must be distinguishable. A key is an attribute or a set of attributes used to identify records and/or establish relationships between tables. The chapter explains four key types.
10.1 Candidate Key
A candidate key is an attribute, or a minimal set of attributes, that can uniquely identify each tuple in a relation. A relation may have more than one candidate key. Each candidate key is eligible to be selected as the primary key.
10.2 Primary Key
A primary key is the candidate key selected by the database designer to uniquely identify tuples in a relation. It must be unique and cannot contain NULL values.
Alternate Key
Candidate keys that are not selected as the primary key are called alternate keys.
10.3 Composite Primary Key
If no single attribute can uniquely identify each tuple, two or more attributes can be combined to form a composite primary key.
- RollNumber alone is not unique because the same student appears on multiple dates.
- AttendanceDate alone is not unique because many students have attendance on the same date.
- The combination (AttendanceDate, RollNumber) uniquely identifies one student's attendance record for one date.
10.4 Foreign Key
A foreign key is an attribute in one relation whose values refer to the primary key of another relation. It represents a relationship between two tables.
- The table containing the foreign key is the referencing/foreign relation.
- The table whose primary key is being referenced is the referenced/primary/master relation.
- A foreign key value must match an existing referenced key value, or be NULL where NULL is permitted.
- STUDENT.GUID is a foreign key referencing GUARDIAN.GUID.
- ATTENDANCE.RollNumber is a foreign key referencing STUDENT.RollNumber.
PK: GUID
PK: RollNumber
FK: GUID
PK: Date + RollNumber
FK: RollNumber
Comparison of all key types
| Key type | Purpose | Example |
|---|---|---|
| Candidate Key | Any minimal unique identifier eligible to become primary key. | GUID and GPhone in GUARDIAN (as stated in the textbook example). |
| Primary Key | Chosen candidate key; uniquely identifies each row. | GUID in GUARDIAN. |
| Alternate Key | Candidate key not selected as primary key. | GPhone if GUID is selected. |
| Composite Primary Key | Combination of two or more attributes used as the primary key. | (AttendanceDate, RollNumber). |
| Foreign Key | References a primary key in another table. | STUDENT.GUID references GUARDIAN.GUID. |
11. Practical SQL Syntax – Supporting Learning Examples
The source chapter introduces queries and SQL as the language used with relational databases, but it does not teach the detailed SQL command syntax in this chapter. The following are additional standard SQL illustrations to make the database concepts practical. SQL syntax can vary slightly between DBMS products.
11.1 CREATE TABLE – defining a table
CREATE TABLE Guardian (
GUID VARCHAR(12) PRIMARY KEY,
GName VARCHAR(60) NOT NULL,
GPhone CHAR(10) UNIQUE,
GAddress VARCHAR(150)
);
Explanation: CREATE TABLE creates a table. PRIMARY KEY identifies each guardian uniquely. NOT NULL requires a value. UNIQUE prevents duplicate phone numbers. VARCHAR stores variable-length text; CHAR stores fixed-length text.
11.2 Creating STUDENT with a foreign key
CREATE TABLE Student (
RollNumber INT PRIMARY KEY,
SName VARCHAR(60) NOT NULL,
SDateofBirth DATE,
GUID VARCHAR(12),
FOREIGN KEY (GUID) REFERENCES Guardian(GUID)
);
Explanation: The GUID column in Student refers to GUID in Guardian. This establishes the relationship between the two tables.
11.3 Creating ATTENDANCE with a composite primary key
CREATE TABLE Attendance (
AttendanceDate DATE,
RollNumber INT,
AttendanceStatus CHAR(1),
PRIMARY KEY (AttendanceDate, RollNumber),
FOREIGN KEY (RollNumber) REFERENCES Student(RollNumber)
);
The combination of AttendanceDate and RollNumber is the primary key. The same student can have attendance records on different dates, but cannot have two records for the same date under this design.
11.4 Inserting a record
INSERT INTO Guardian
(GUID, GName, GPhone, GAddress)
VALUES
('444444444444', 'Amit Ahuja',
'5711492685', 'Ashok Vihar, Delhi');
INSERT INTO adds a new row. The values must follow the listed column order when column names are supplied.
11.5 Retrieving records using SELECT
SELECT * FROM Student;
SELECT SName, RollNumber
FROM Student;
SELECT *
FROM Attendance
WHERE AttendanceDate = '2018-09-01'
AND AttendanceStatus = 'P';
SELECT retrieves data. The asterisk (*) means all columns. WHERE filters rows according to a condition.
11.6 Updating a record
UPDATE Guardian
SET GPhone = '9876543210'
WHERE GUID = '444444444444';
UPDATE changes existing data. The WHERE clause is essential to target the intended record; without it, every row may be updated.
11.7 Deleting a record
DELETE FROM Guardian
WHERE GUID = '444444444444';
DELETE removes matching rows. A referenced guardian may not be deletable while student records still refer to that guardian, depending on the foreign-key rules configured.
11.8 Useful constraint keywords
| SQL keyword | Meaning | Illustration |
|---|---|---|
| PRIMARY KEY | Unique identifier; cannot be NULL. | RollNumber INT PRIMARY KEY |
| FOREIGN KEY | Links to a key in another table. | FOREIGN KEY (GUID) REFERENCES Guardian(GUID) |
| UNIQUE | Prevents duplicate values. | GPhone CHAR(10) UNIQUE |
| NOT NULL | Requires a value. | GName VARCHAR(60) NOT NULL |
| CHECK | Requires a condition to be true. | CHECK (AttendanceStatus IN ('P','A')) |
11.9 Adding a CHECK constraint (illustration)
CREATE TABLE AttendanceExample (
AttendanceDate DATE,
RollNumber INT,
AttendanceStatus CHAR(1)
CHECK (AttendanceStatus IN ('P', 'A')),
PRIMARY KEY (AttendanceDate, RollNumber)
);
12. Complete Chapter Summary
- A file is a container used to store data in a computer.
- File systems face limitations such as difficulty in access, redundancy, inconsistency, isolation, dependence and difficulty in controlled sharing.
- A DBMS is software used to create and manage databases.
- A database is an organised collection of logically related data; in a relational database, data is stored in related tables.
- A database schema describes the database structure.
- A constraint is a restriction on the values that can be stored.
- Schema and constraints are recorded in the database catalog/data dictionary as metadata.
- The database instance is the snapshot of database contents at a particular time.
- A query is a request to retrieve information or manipulate data.
- The basic data-manipulation operations are insertion, deletion and update.
- A database engine processes database operations and queries.
- In a relational model, a table is a relation, a column is an attribute and a row is a tuple.
- Domain means the permitted set of values for an attribute.
- Degree is the number of attributes; cardinality is the number of tuples.
- Relation attributes have unique names; row and column order are immaterial.
- Tuples must be distinct; values in an attribute must come from the same domain and be atomic. NULL represents unknown or non-applicable information.
- A candidate key can uniquely identify tuples; one candidate key is selected as the primary key.
- A candidate key not selected as primary key is an alternate key.
- A composite primary key contains more than one attribute.
- A foreign key refers to a primary key in another relation and connects tables.
- SQL is a standard language used to work with relational database systems such as MySQL.
13. Solved Textbook Exercises
The following answers address the exercise questions included in the uploaded chapter. Explanations are included so that students understand the reasoning, not just the final term.
Q1. Give the terms for each description.
- Collection of logically related records – Database.
- File containing description about data stored in the database – Data dictionary / database catalog (metadata).
- Attribute that can uniquely identify tuples – Candidate key.
- Special value used when the actual value is unknown – NULL.
- Unique attribute not selected as the primary key – Alternate key.
- Software used to create, manipulate and maintain a relational database – RDBMS (Relational Database Management System).
Q2. Why are foreign keys allowed to have NULL values? Explain with an example.
A foreign key may be NULL when the relationship is optional or the related record is not yet known, provided that the foreign-key column is not part of the primary key and the table definition permits NULL. For example, a STUDENT record may temporarily have GUID = NULL if guardian details have not yet been provided. A non-NULL foreign-key value must refer to an existing key in the referenced table.
Q3. Differentiate between (a) database state and schema, (b) primary key and foreign key, (c) degree and cardinality.
| Basis | First term | Second term |
|---|---|---|
| (a) | Schema: design/structure of the database; changes relatively rarely. | State/instance: actual data snapshot at a particular time; changes when data is inserted, updated or deleted. |
| (b) | Primary key: uniquely identifies each row in its own table; cannot be NULL. | Foreign key: refers to a key in another table to establish a relationship; may be NULL if permitted. |
| (c) | Degree: number of columns/attributes. | Cardinality: number of rows/tuples. |
Q4. Compared with a file system, how does a DBMS avoid data redundancy?
A DBMS organises logically related data into separate related tables and links them through keys. For example, guardian details are stored once in GUARDIAN. STUDENT stores only GUID to refer to the guardian, rather than repeating the guardian's name, phone and address for every sibling. This reduces unnecessary duplication.
Q5. What file-system limitations can be overcome by a relational DBMS?
A relational DBMS helps address difficulty in data access, data redundancy, data inconsistency, data isolation, data dependence and controlled data sharing through structured tables, relationships, queries, constraints and access-control facilities. The extent of each benefit depends on correct database design and configuration.
Q6. Sports Preferences table – answer parts (a), (b) and (c).
Given records include Roll_no 9–Cricket, 13–Football, 17–Badminton, 17–Football, 21–Hockey, 24–NULL and NULL–Kabaddi.
- Can Roll_no 24 have NULL Preference? If the school rule requires every student to select one sport, NULL is not appropriate because it means the preference is unknown or not applicable. A NOT NULL constraint should be used on Preference to enforce a required value.
- Roll_no 17 has two preferences. If each student must have only one preference, Roll_no should be unique in this relation. A primary key or UNIQUE constraint on Roll_no would prevent two rows for the same student. The duplicate violates the intended uniqueness rule for one preference per student.
- Can NULL–Kabaddi be stored? No, not if Roll_no is the primary key, because a primary key cannot be NULL. The fact that no student chose Kabaddi does not require a row with a NULL roll number.
Q7. Are the states of the two Sports Preferences relations equivalent?
Yes. The same five student–sport pairings appear in both tables. The second relation is displayed in a different row order and with the columns in a different order. In a relation, the order of tuples and the order of attributes are immaterial, provided the attribute names and their corresponding values represent the same information.
Q8. Design a database for the school canteen.
(a) Item relation: Create an ITEM table with ItemID, ItemName and Price. ItemID should be a primary key; ItemName may also be UNIQUE if the business rule says item names cannot repeat. Store each item's name and price once.
ITEM(ItemID, ItemName, Price)
Primary key: ItemID(b) Purchase/bill relation: Store transaction-specific quantity in a separate BILL_ITEM table, not in ITEM, because the quantity purchased changes from one order to another. A suitable design is:
BILL(BillID, BillDate, StudentID)
Primary key: BillID
BILL_ITEM(BillID, ItemID, Quantity)
Composite primary key: (BillID, ItemID)
Foreign key: BillID references BILL(BillID)
Foreign key: ItemID references ITEM(ItemID)BillID uniquely identifies a bill. ItemID ensures that a purchased item must exist in ITEM. The composite key prevents the same item from being entered twice on the same bill; multiple items can appear on one bill. If the school permits repeated lines for the same item, a separate BillLineID can be used instead.
(c) Calories: Store calories in ITEM if calories are an inherent property of each item and do not vary by order. If calories depend on portion size or recipe version, the design would need to represent that separately.
Q9. EMPLOYEE and DEPENDENT database.
Given:
EMPLOYEE(AadharNumber, Name, Address, Department, EmployeeID)
DEPENDENT(EmployeeID, DependentName, Relationship)- Candidate keys in EMPLOYEE: AadharNumber and EmployeeID, assuming each is unique and non-NULL as intended by the design.
- Retrieve dependents of an employee: Use EMPLOYEE and DEPENDENT, linked by EmployeeID. EmployeeID is the primary key in EMPLOYEE and a foreign key in DEPENDENT. A join on EmployeeID retrieves the employee's dependents.
- Degree: EMPLOYEE has 5 attributes; DEPENDENT has 3 attributes.
SELECT E.Name, D.DependentName, D.Relationship
FROM EMPLOYEE AS E
JOIN DEPENDENT AS D
ON E.EmployeeID = D.EmployeeID;Q10. SCHOOL_UNIFORM database – determine whether tuples can be inserted.
UNIFORM has attributes UCode, UName, UColor with UCode as primary key and UName NOT NULL. COST has UCode, Size, Price; (UCode, Size) is the composite primary key and Price must be greater than 0. COST.UCode is understood to refer to a valid uniform code.
(a) UNIFORM:
(7, Handkerchief, NULL)– Allowed under the stated constraints: UCode 7 is new, UName is supplied, and no NOT NULL rule is shown for UColor.(4, Ribbon, Red)– Not allowed: UCode 4 already exists and UCode is the primary key.(8, NULL, White)– Not allowed: UName is NOT NULL.
(b) COST:
(7, S, 0)– Not allowed: Price must be greater than 0.(9, XL, 100)– Allowed under the constraints explicitly shown in the textbook diagram: the (UCode, Size) combination is new and Price is greater than 0. The diagram does not explicitly list a foreign-key constraint on COST.UCode. If a foreign key to UNIFORM.UCode were additionally defined, this row would be rejected because UCode 9 is not present in UNIFORM.
Q11. MOVIE and AUDI relations – identify appropriate keys.
Given MOVIE(Movie_ID, MovieName, ReleaseDate) and AUDI(AudiNo, Movie_ID, Seats, ScreenType, TicketPrice). One movie can be screened in more than one auditorium.
- MOVIE: Movie_ID is an appropriate primary key if each movie has a unique Movie_ID.
- AUDI: AudiNo can be the primary key if it uniquely identifies each auditorium in the multiplex. Movie_ID should not be the primary key of AUDI because the same movie may be shown in multiple auditoriums and therefore Movie_ID can repeat in AUDI.
- Foreign key: AUDI.Movie_ID references MOVIE.Movie_ID.
Q12. STUDENT–PROJECT database – identify keys.
From the given tables:
- STUDENT(RollNo, Name, Class, Section, Registration_ID)
- PROJECT(ProjectNo, PName, SubmissionDate)
- PROJECT_ASSIGNED(Registration_ID, ProjectNo)
- Primary keys: STUDENT – RollNo; PROJECT – ProjectNo; PROJECT_ASSIGNED – composite key (Registration_ID, ProjectNo), assuming each student may be assigned a project and the pair is unique.
- Foreign keys in PROJECT_ASSIGNED: Registration_ID references STUDENT.Registration_ID; ProjectNo references PROJECT.ProjectNo.
- Alternate key in STUDENT: Registration_ID is an alternate key if it is unique and RollNo is selected as the primary key.
- Can RollNo be duplicated? No. RollNo is the primary key and must uniquely identify every student.
Q13. Can the listed operations be performed in STUDENT–PROJECT?
- Insert student with missing RollNo: No. RollNo is the primary key and cannot be NULL.
- Insert student with missing Registration_ID: No, if Registration_ID is defined as an alternate key/UNIQUE and NOT NULL as required for a candidate key. The displayed schema identifies it as a unique student registration identifier; it must be supplied for that design.
- Insert project without SubmissionDate: It depends on the constraint. The supplied chapter diagram does not show a NOT NULL constraint for SubmissionDate. If no NOT NULL constraint is defined, the date may be NULL; otherwise it cannot.
- Insert PROJECT_ASSIGNED record (IP-101-19, 206): No, if both columns are foreign keys, because Registration_ID IP-101-19 is not present in STUDENT and ProjectNo 206 is not present in PROJECT. Both references must point to existing records.
14. Quick Revision – Important Examination Points
- File: container for storing data.
- DBMS: software to create and manage databases.
- RDBMS: DBMS based on related tables/relations.
- Redundancy: unnecessary duplication of data.
- Inconsistency: conflicting copies of the same data.
- Schema: database design.
- Instance: database snapshot at a given time.
- Metadata: data about data.
- Attribute: column.
- Tuple: row.
- Domain: allowed set of values for an attribute.
- Degree: number of columns.
- Cardinality: number of rows.
- Candidate key: minimal unique identifier candidate.
- Primary key: selected candidate key.
- Alternate key: candidate key not selected as primary key.
- Composite primary key: primary key made from multiple attributes.
- Foreign key: attribute(s) referencing a key in another table.
- NULL: unknown or non-applicable value; not the same as zero.
- Data manipulation: INSERT, DELETE and UPDATE operations.
Common mistakes to avoid
- Do not confuse degree with cardinality: degree counts columns; cardinality counts rows.
- Do not confuse schema with instance: schema is structure; instance is current data.
- Do not assume a foreign key must be unique. Multiple rows may refer to the same parent row.
- Do not use a name as a primary key unless uniqueness and non-NULL requirements are guaranteed.
- Do not treat NULL as zero or an empty string.
- Do not store multiple values in one attribute cell in a properly designed relation.
- Remember that a composite key is a combination of attributes, not merely any two columns.
TEXTBOOK SOLUTION
Step-by-step solved textbook exercises, derivations, and solutions.
13. Solved Textbook Exercises
The following answers address the exercise questions included in the uploaded chapter. Explanations are included so that students understand the reasoning, not just the final term.
Q1. Give the terms for each description.
- Collection of logically related records – Database.
- File containing description about data stored in the database – Data dictionary / database catalog (metadata).
- Attribute that can uniquely identify tuples – Candidate key.
- Special value used when the actual value is unknown – NULL.
- Unique attribute not selected as the primary key – Alternate key.
- Software used to create, manipulate and maintain a relational database – RDBMS (Relational Database Management System).
Q2. Why are foreign keys allowed to have NULL values? Explain with an example.
A foreign key may be NULL when the relationship is optional or the related record is not yet known, provided that the foreign-key column is not part of the primary key and the table definition permits NULL. For example, a STUDENT record may temporarily have GUID = NULL if guardian details have not yet been provided. A non-NULL foreign-key value must refer to an existing key in the referenced table.
Q3. Differentiate between (a) database state and schema, (b) primary key and foreign key, (c) degree and cardinality.
| Basis | First term | Second term |
|---|---|---|
| (a) | Schema: design/structure of the database; changes relatively rarely. | State/instance: actual data snapshot at a particular time; changes when data is inserted, updated or deleted. |
| (b) | Primary key: uniquely identifies each row in its own table; cannot be NULL. | Foreign key: refers to a key in another table to establish a relationship; may be NULL if permitted. |
| (c) | Degree: number of columns/attributes. | Cardinality: number of rows/tuples. |
Q4. Compared with a file system, how does a DBMS avoid data redundancy?
A DBMS organises logically related data into separate related tables and links them through keys. For example, guardian details are stored once in GUARDIAN. STUDENT stores only GUID to refer to the guardian, rather than repeating the guardian's name, phone and address for every sibling. This reduces unnecessary duplication.
Q5. What file-system limitations can be overcome by a relational DBMS?
A relational DBMS helps address difficulty in data access, data redundancy, data inconsistency, data isolation, data dependence and controlled data sharing through structured tables, relationships, queries, constraints and access-control facilities. The extent of each benefit depends on correct database design and configuration.
Q6. Sports Preferences table – answer parts (a), (b) and (c).
Given records include Roll_no 9–Cricket, 13–Football, 17–Badminton, 17–Football, 21–Hockey, 24–NULL and NULL–Kabaddi.
- Can Roll_no 24 have NULL Preference? If the school rule requires every student to select one sport, NULL is not appropriate because it means the preference is unknown or not applicable. A NOT NULL constraint should be used on Preference to enforce a required value.
- Roll_no 17 has two preferences. If each student must have only one preference, Roll_no should be unique in this relation. A primary key or UNIQUE constraint on Roll_no would prevent two rows for the same student. The duplicate violates the intended uniqueness rule for one preference per student.
- Can NULL–Kabaddi be stored? No, not if Roll_no is the primary key, because a primary key cannot be NULL. The fact that no student chose Kabaddi does not require a row with a NULL roll number.
Q7. Are the states of the two Sports Preferences relations equivalent?
Yes. The same five student–sport pairings appear in both tables. The second relation is displayed in a different row order and with the columns in a different order. In a relation, the order of tuples and the order of attributes are immaterial, provided the attribute names and their corresponding values represent the same information.
Q8. Design a database for the school canteen.
(a) Item relation: Create an ITEM table with ItemID, ItemName and Price. ItemID should be a primary key; ItemName may also be UNIQUE if the business rule says item names cannot repeat. Store each item's name and price once.
ITEM(ItemID, ItemName, Price)
Primary key: ItemID(b) Purchase/bill relation: Store transaction-specific quantity in a separate BILL_ITEM table, not in ITEM, because the quantity purchased changes from one order to another. A suitable design is:
BILL(BillID, BillDate, StudentID)
Primary key: BillID
BILL_ITEM(BillID, ItemID, Quantity)
Composite primary key: (BillID, ItemID)
Foreign key: BillID references BILL(BillID)
Foreign key: ItemID references ITEM(ItemID)BillID uniquely identifies a bill. ItemID ensures that a purchased item must exist in ITEM. The composite key prevents the same item from being entered twice on the same bill; multiple items can appear on one bill. If the school permits repeated lines for the same item, a separate BillLineID can be used instead.
(c) Calories: Store calories in ITEM if calories are an inherent property of each item and do not vary by order. If calories depend on portion size or recipe version, the design would need to represent that separately.
Q9. EMPLOYEE and DEPENDENT database.
Given:
EMPLOYEE(AadharNumber, Name, Address, Department, EmployeeID)
DEPENDENT(EmployeeID, DependentName, Relationship)- Candidate keys in EMPLOYEE: AadharNumber and EmployeeID, assuming each is unique and non-NULL as intended by the design.
- Retrieve dependents of an employee: Use EMPLOYEE and DEPENDENT, linked by EmployeeID. EmployeeID is the primary key in EMPLOYEE and a foreign key in DEPENDENT. A join on EmployeeID retrieves the employee's dependents.
- Degree: EMPLOYEE has 5 attributes; DEPENDENT has 3 attributes.
SELECT E.Name, D.DependentName, D.Relationship
FROM EMPLOYEE AS E
JOIN DEPENDENT AS D
ON E.EmployeeID = D.EmployeeID;Q10. SCHOOL_UNIFORM database – determine whether tuples can be inserted.
UNIFORM has attributes UCode, UName, UColor with UCode as primary key and UName NOT NULL. COST has UCode, Size, Price; (UCode, Size) is the composite primary key and Price must be greater than 0. COST.UCode is understood to refer to a valid uniform code.
(a) UNIFORM:
(7, Handkerchief, NULL)– Allowed under the stated constraints: UCode 7 is new, UName is supplied, and no NOT NULL rule is shown for UColor.(4, Ribbon, Red)– Not allowed: UCode 4 already exists and UCode is the primary key.(8, NULL, White)– Not allowed: UName is NOT NULL.
(b) COST:
(7, S, 0)– Not allowed: Price must be greater than 0.(9, XL, 100)– Allowed under the constraints explicitly shown in the textbook diagram: the (UCode, Size) combination is new and Price is greater than 0. The diagram does not explicitly list a foreign-key constraint on COST.UCode. If a foreign key to UNIFORM.UCode were additionally defined, this row would be rejected because UCode 9 is not present in UNIFORM.
Q11. MOVIE and AUDI relations – identify appropriate keys.
Given MOVIE(Movie_ID, MovieName, ReleaseDate) and AUDI(AudiNo, Movie_ID, Seats, ScreenType, TicketPrice). One movie can be screened in more than one auditorium.
- MOVIE: Movie_ID is an appropriate primary key if each movie has a unique Movie_ID.
- AUDI: AudiNo can be the primary key if it uniquely identifies each auditorium in the multiplex. Movie_ID should not be the primary key of AUDI because the same movie may be shown in multiple auditoriums and therefore Movie_ID can repeat in AUDI.
- Foreign key: AUDI.Movie_ID references MOVIE.Movie_ID.
Q12. STUDENT–PROJECT database – identify keys.
From the given tables:
- STUDENT(RollNo, Name, Class, Section, Registration_ID)
- PROJECT(ProjectNo, PName, SubmissionDate)
- PROJECT_ASSIGNED(Registration_ID, ProjectNo)
- Primary keys: STUDENT – RollNo; PROJECT – ProjectNo; PROJECT_ASSIGNED – composite key (Registration_ID, ProjectNo), assuming each student may be assigned a project and the pair is unique.
- Foreign keys in PROJECT_ASSIGNED: Registration_ID references STUDENT.Registration_ID; ProjectNo references PROJECT.ProjectNo.
- Alternate key in STUDENT: Registration_ID is an alternate key if it is unique and RollNo is selected as the primary key.
- Can RollNo be duplicated? No. RollNo is the primary key and must uniquely identify every student.
Q13. Can the listed operations be performed in STUDENT–PROJECT?
- Insert student with missing RollNo: No. RollNo is the primary key and cannot be NULL.
- Insert student with missing Registration_ID: No, if Registration_ID is defined as an alternate key/UNIQUE and NOT NULL as required for a candidate key. The displayed schema identifies it as a unique student registration identifier; it must be supplied for that design.
- Insert project without SubmissionDate: It depends on the constraint. The supplied chapter diagram does not show a NOT NULL constraint for SubmissionDate. If no NOT NULL constraint is defined, the date may be NULL; otherwise it cannot.
- Insert PROJECT_ASSIGNED record (IP-101-19, 206): No, if both columns are foreign keys, because Registration_ID IP-101-19 is not present in STUDENT and ProjectNo 206 is not present in PROJECT. Both references must point to existing records.
MCQ
High-yield board questions, previous year questions (PYQs), and model answer keys.
Database Concepts – 50 MCQ Practice Test
Practice questions covering file systems, DBMS, database structure, relational data models and keys. Select one answer for each question, submit your test and review the explanations.
Test Result
Correct: 0 | Incorrect: 0 | Unanswered: 0