Chapter 01
Database Concepts & Relational Architecture
5 topics · 4 sections · beginner-friendly study notes · Updated
A DBMS (Database Management System) is software that stores, protects and manages data for many users at the same time.
Data is kept in tables (relations), designed with ER diagrams, and identified by keys.
Every other DBMS chapter builds on tables, keys and ER design.
Keys, data independence and "minimum number of tables" are favourite GATE and semester questions.
Designing the database of a bank, college, hospital, hotel booking site or online shop.
File System vs DBMS
A DBMS is software that lets users define, create, store, update and control a database. A file system just stores raw files, and every program must understand the file format by itself.
In short: A file system is a cupboard full of loose papers. A DBMS is a trained librarian who keeps everything organised, safe and easy to find.
Think about it
File systems become messy as data grows. A DBMS was created to remove redundancy, protect data and let many users share it safely. A bank cannot afford two different balances for one account. A DBMS makes sure there is only one correct balance and that two clerks cannot spoil it by updating at the same time.
Imagine a bank that keeps customer data in separate files for savings, loans and cards.
The same customer address is stored three times.
When the customer moves, one file is updated and two are forgotten.
This is data redundancy and inconsistency.
A DBMS keeps one copy of each fact in one place and shares it with every application.
It also controls who can see the data, lets many users work together safely, and recovers the data after a crash.
Key points
- Database: An organised collection of related data.
- DBMS: Software that manages the database (MySQL, Oracle, PostgreSQL, SQL Server).
- DBA: Database Administrator, the person who manages and secures the database.
- Redundancy: The same data stored in many places.
- DBMS languages: DDL defines tables, DML changes data, DCL controls permissions, TCL controls transactions. (Writing queries is covered in the SQL subject.)
- GATE tip: the main benefits are reduced redundancy, integrity, concurrency control, security and data independence.
Problems of a file system
Data redundancy and inconsistency; difficult data access (new program for every new question); data isolation in many formats; weak integrity checks; no atomic updates; concurrent-access problems; poor security.
Advantages of a DBMS
Less redundancy, consistent data, data sharing, strong security, integrity constraints, backup and recovery, data independence, and a standard query language (SQL).
Disadvantages of a DBMS
Costly software and hardware, needs trained staff (DBA), more complex than plain files, and a failure of the central system can affect many applications.
3-Tier Schema Architecture
The three-schema (ANSI/SPARC) architecture divides a database into three levels: the external level (user views), the conceptual level (the whole logical design) and the internal level (physical storage).
In short: Users see a simple screen (view). Designers see tables (conceptual). The computer sees files and disk blocks (internal). Each level hides the details below it.
Think about it
It lets many users see the same data in different ways while the storage and the design can change without breaking everyone. In a college database, the student sees marks and attendance, the accounts office sees fee records, and the DBA sees tables and indexes. They all use the same database.
External level: each user group sees only the part of the data it needs.
A bank teller sees balances, but not the staff salaries.
Conceptual level: one description of the whole database, such as tables, columns, keys and rules.
There is only one conceptual schema.
Internal level: how the data is really stored, such as files, indexes and blocks on disk.
Between the levels sit mappings that translate a request from one level to the next.
Do not confuse this with the 3-tier application architecture (client, server, database).
That one is about how software is deployed, while the schema architecture is about how data is hidden.
Key points
- External level (view level): Many views, one for each user group.
- Conceptual level (logical level): Exactly one schema for the whole database: tables, keys, constraints.
- Internal level (physical level): Exactly one schema describing files, indexes and storage.
- Mapping: Rules that convert data between two neighbouring levels.
- Schema vs instance: Schema is the design (changes rarely). Instance is the data stored at one moment (changes often).
- Many external schemas, one conceptual schema, one internal schema.
- Views provide security because users only see what the view shows.
Example
CodeA view is the external level: -- External level: a view that hides private columns CREATE VIEW student_public AS SELECT roll_no, name FROM student;
Data Independence
Data independence is the ability to change the schema at one level without changing the schema at the next higher level. Physical data independence changes the internal level without touching the conceptual level. Logical data independence changes the conceptual level without touching the external views or programs.
In short: You can rearrange the cupboard (storage) without changing the list of items (tables), and you can add new items to the list without disturbing every reader (views).
Think about it
Applications live for many years. Data independence lets the DBA tune and redesign the database without rewriting all those applications. When a bank moves its data to faster SSD disks, mobile apps keep working without any change. That is physical data independence.
Physical data independence examples: adding an index, moving a table to a new disk, changing the file organisation, changing the block size.
Queries stay the same, only speed changes.
Logical data independence examples: adding a new column or table, or splitting a table while a view keeps the old shape.
Logical independence is harder to achieve, because programs depend heavily on the table structure.
If you drop a column that a view uses, the view will still break.
File systems have almost no data independence, because the record format is written inside every program.
Key points
- Physical data independence: Change storage (internal) without changing tables (conceptual).
- Logical data independence: Change tables (conceptual) without changing views or programs.
- Logical data independence is harder to achieve than physical data independence.
- Quick test: only storage changed
→physical. Table design changed but old programs still work→logical.
Read more
Example
CodeAdding an index: -- Physical independence: add an index. No table or query changes. CREATE INDEX idx_student_name ON student(name);
ER Modeling & Cardinality
The Entity-Relationship (ER) model shows data as entities (things), attributes (properties) and relationships (links between entities). Cardinality says how many entities can be linked: 1:1, 1:N or M:N.
In short: ER diagram is a map of your data drawn before you create tables. Boxes are things, ovals are details, and diamonds show how things are connected.
Think about it
A good ER diagram avoids design mistakes early. It is cheaper to fix a diagram than a running database. In a bank: Customer HAS Account is 1:N, because one customer can have many accounts but an account belongs to one customer (for this simple example).
Entity: a thing we store data about, such as Student or Account.
Attribute: a property, such as name or balance.
A key attribute is underlined.
A multivalued attribute (phone numbers) has a double oval; a derived attribute (age from date of birth) has a dashed oval.
Relationship: an association, such as Student ENROLLS Course.
Cardinality: 1:1 (one person, one passport), 1:N (one department, many employees), M:N (many students, many courses).
Participation: total (every entity must take part, double line) or partial (optional).
A weak entity has no key of its own.
It depends on an owner entity, for example Dependent of Employee, and uses a partial key plus the owner key.
Key points
- Entity: A real-world thing that has data stored about it.
- Weak entity: Entity without its own key; depends on an owner entity.
- Cardinality: 1:1, 1:N or M:N: how many entities are linked.
- Total participation: Every entity must be in the relationship.
- Generalization / specialization: Bottom-up merging into a super class / top-down splitting into sub classes.
- For "minimum number of tables": merge 1:1 and 1:N relationships into an entity table. Every M:N relationship always needs its own table.
Example
CodeMapping an M:N relationship: -- M:N relationship Student-Course becomes its own table CREATE TABLE enrolment ( roll_no INT, course_id INT, grade CHAR(2), PRIMARY KEY (roll_no, course_id), FOREIGN KEY (roll_no) REFERENCES student(roll_no), FOREIGN KEY (course_id) REFERENCES course(course_id) );
Rules to convert ER to tables
1) Strong entity becomes a table.
2) Multivalued attribute becomes a separate table.
3) Weak entity becomes a table with the owner key as foreign key, and key = owner key + partial key.
4) 1:N relationship puts the key of the 1-side into the N-side table as a foreign key.
5) M:N relationship needs its own table with both keys.
6) 1:1 relationship puts a foreign key on either side (prefer the side with total participation).
Database Keys
A key is an attribute (or a set of attributes) that identifies a row. A super key is any set that is unique. A candidate key is a minimal super key. The primary key is the candidate key we choose. A foreign key points to a key in another table.
In short: A key is like a roll number or account number: it picks exactly one row from the table.
Think about it
Keys decide how rows are identified, linked and protected from duplicates. Normalization in the next chapter depends fully on keys. In a college, roll_no is a candidate key and so is email. We choose roll_no as the primary key. Then email becomes an alternate key. In the marks table, roll_no is a foreign key pointing back to the student table.
Super key: any set of attributes that makes every row unique (it may contain extra attributes).
Candidate key: a super key where removing any attribute breaks uniqueness.
Primary key: the one candidate key chosen by the designer; it cannot be NULL.
Alternate key: a candidate key that was not chosen.
Foreign key: a column whose values must match a key of another table, which links the two tables (referential integrity).
Composite key: a key made of two or more attributes.
Prime attribute: part of some candidate key.
If a table has n attributes and one candidate key with k attributes, the number of super keys is 2^(n-k).
Key points
- Super key: Any attribute set that identifies rows uniquely.
- Candidate key: A minimal super key.
- Primary key: The chosen candidate key; not NULL and unique.
- Foreign key: Column that refers to a key of another (or the same) table.
- Prime attribute: An attribute that belongs to at least one candidate key.
- Every candidate key is a super key, but not every super key is a candidate key.
- A table can have many candidate keys but only one primary key.
- Entity integrity: a primary key can never be NULL. Referential integrity: a foreign key must match an existing key or be NULL.
Example
CodePrimary, alternate and foreign keys: CREATE TABLE department ( dept_id INT PRIMARY KEY, dept_name VARCHAR(50) UNIQUE ); CREATE TABLE student ( roll_no INT PRIMARY KEY, email VARCHAR(100) UNIQUE, name VARCHAR(60), dept_id INT, FOREIGN KEY (dept_id) REFERENCES department(dept_id) );
Solved examples
Table Student(roll_no, email, name, phone). Both roll_no and email are unique. Name the candidate keys, a primary key choice and an alternate key.
Classify the keys
Formula Applied:—Approach note: Candidate keys are the choices. The primary key is the one you pick.
R(A, B, C, D) has candidate keys {A} and {B, C}. How many super keys does R have?
Number of super keys
Formula Applied:—Approach note: With several candidate keys, use inclusion-exclusion.
ER diagram: Employee works_in Department (N:1). Employee and Project are linked by an M:N relationship works_on. What is the minimum number of tables?
Minimum tables
Formula Applied:—Approach note: 1:1 and 1:N merge into an entity table. M:N always adds one table.
A DBA adds an index on the account_no column of a bank table. Which kind of data independence is this?
Identify the data independence type
Formula Applied:—Approach note: Storage change only → physical.
Real-world applications
Using Database Concepts & Relational Architecture in real projects
Designing the database of a bank, college, hospital, hotel booking site or online shop.
Common mistakes
❌ Myth: A primary key can have one NULL value.
Why this is wrong: Entity integrity says that no part of a primary key can be NULL.
✅ Verified Truth: A primary key is always unique and NOT NULL.
⚠️ Exam Tip: Quote the phrase "entity integrity" in the exam.
❌ Myth: A table has only one candidate key.
Why this is wrong: Many different minimal sets can identify a row.
✅ Verified Truth: A table can have many candidate keys but only one primary key.
⚠️ Exam Tip: Always search for all candidate keys before deciding the primary key.
❌ Myth: The 3-tier schema architecture and the 3-tier application architecture are the same.
Why this is wrong: One is about hiding data levels; the other is about client, server and database machines.
✅ Verified Truth: Schema architecture = external, conceptual, internal. Application architecture = presentation, application, data.
⚠️ Exam Tip: Read the question carefully for the word "schema".
Revision notes
A DBMS (Database Management System) is software that stores, protects and manages data for many users at the same time. Data is kept in tables (relations), designed with ER diagrams, and identified by keys.
High-Yield Quick Revision Points
- DBMS removes redundancy, inconsistency and gives security, sharing and recovery
- Three levels: external (many) → conceptual (one) → internal (one)
- Physical independence is easier than logical independence
- ER: entity, attribute, relationship; cardinality 1:1, 1:N, M:N
- M:N needs a new table; 1:N puts FK on the N side
- Weak entity key = owner key + partial key
- Super key ⊇ candidate key ⊇ primary key
- Super keys = 2^(n−k) for one candidate key of size k
Practice questions
Which constraint makes sure a foreign key value exists in the parent table?
R(A, B, C) has the single candidate key A. How many super keys does R have?
Changing the storage structure without changing the table design shows:
An M:N relationship set is converted into:
How many conceptual schemas does a database have?