Part 1: High-Yield Revision Notes (Quick Theory)
1. Database System Concepts & Architecture
DBMS vs. File System: DBMS reduces data redundancy, eliminates data inconsistency, provides data isolation, ensures security, and supports concurrent access and ACID properties.
Three-Schema Architecture (ANSI-SPARC):
External Level (View Level): Highest level; defines how end-users view the data.
Conceptual Level (Logical Level): Defines what data is stored in the database and the relationships among them (e.g., tables, constraints).
Internal Level (Physical Level): Lowest level; describes how data is physically stored on disk (e.g., file structures, indexes).
Data Independence:
Logical Data Independence: Ability to modify the conceptual schema without altering external schemas or application programs.
Physical Data Independence: Ability to modify the physical schema (e.g., adding indexes) without altering the conceptual schema.
2. Relational Data Model & Keys
Relational Terminology:
Relation: Table
Tuple: Row / Record
Attribute: Column / Field
Cardinality: Total number of tuples (rows) in a relation.
Degree: Total number of attributes (columns) in a relation.
Database Keys:
Super Key: A set of one or more attributes that uniquely identifies a tuple.
Candidate Key: A minimal Super Key (no redundant attributes).
Primary Key: A candidate key selected by the database designer to uniquely identify tuples (Cannot contain
NULLvalues).Alternate Key: Candidate keys that were not chosen as the Primary Key.
Foreign Key: An attribute in a relation that refers to the Primary Key of another relation (Enforces Referential Integrity).
3. Database Normalization
Normalization minimizes data redundancy and prevents update/insertion/deletion anomalies.
| Normal Form | Key Condition / Rule |
| 1NF (First Normal Form) | Attributes must contain atomic (indivisible) values only (No composite or multi-valued attributes). |
| 2NF (Second Normal Form) | Must be in 1NF AND no non-prime attribute should be functionally dependent on a proper subset of any candidate key (Eliminates Partial Dependency). |
| 3NF (Third Normal Form) | Must be in 2NF AND no non-prime attribute should depend on another non-prime attribute (Eliminates Transitive Dependency: $X \rightarrow Y$ where neither $X$ is a superkey nor $Y$ is a prime attribute). |
| BCNF (Boyce-Codd Normal Form) | A stricter version of 3NF. For every non-trivial functional dependency $X \rightarrow Y$, $X$ must be a Super Key. |
4. Transaction Processing & ACID Properties
A Transaction is a logical unit of database processing.
ACID Properties:
Atomicity: All-or-nothing execution. Handled by the Transaction Manager / Recovery Manager using log files (
COMMIT/ROLLBACK).Consistency: Database moves from one valid state to another. Enforced by database constraints and application programmers.
Isolation: Concurrent transactions execute without interfering with each other. Managed by the Concurrency Control Manager (e.g., Locking protocols, Timestamping).
Durability: Changes made by committed transactions persist permanently in non-volatile memory even after system crashes. Handled by Recovery Manager.
5. SQL Commands Classification
SQL Commands
|
+-----------------+------------+------------+-----------------+
| | | |
DDL DML DCL TCL
(Data Definition) (Data Manipulation) (Data Control) (Transaction Control)
- CREATE - INSERT - GRANT - COMMIT
- ALTER - UPDATE - REVOKE - ROLLBACK
- DROP - DELETE - SAVEPOINT
- TRUNCATE - SELECT
Important Difference:
DELETEis a DML command (Deletes specific rows, can be rolled back, fires triggers).
TRUNCATEis a DDL command (Deletes all rows instantly, resets identity counter, cannot be rolled back in most systems, faster thanDELETE).
DROPis a DDL command (Removes table structure along with its data permanently).
Part 2: Top 35 Important MCQs (With Solutions)
Which level of the ANSI-SPARC architecture describes how data is physically stored in the storage device?
Answer: Internal / Physical Level
The number of tuples (rows) in a relation is known as its:
Answer: Cardinality
The number of attributes (columns) in a relation is known as its:
Answer: Degree
Which key uniquely identifies a row in a table and cannot contain
NULLvalues?Answer: Primary Key
A minimal super key is formally defined as a:
Answer: Candidate Key
The constraint that requires a Foreign Key value to match an existing Primary Key value in a referenced table is called:
Answer: Referential Integrity Constraint
In a relational model, an attribute that can be divided into sub-parts is called a:
Answer: Composite Attribute
Which normal form eliminates partial dependency?
Answer: Second Normal Form (2NF)
Transitive dependency is completely removed in which normal form?
Answer: Third Normal Form (3NF)
A relation is in BCNF if for every non-trivial functional dependency $X \rightarrow Y$:
Answer: $X$ is a Super Key
Which component of the ACID properties ensures that either all operations of a transaction execute or none do?
Answer: Atomicity
Which component of DBMS manages concurrent execution of transactions to ensure Isolation?
Answer: Concurrency Control Manager
Which SQL command category does
TRUNCATEbelong to?Answer: DDL (Data Definition Language)
What is the main difference between
DELETEandTRUNCATEcommands?Answer:
DELETEis DML (can delete specific rows and be rolled back), whereasTRUNCATEis DDL (removes all rows and cannot be easily rolled back).
Which SQL clause is used to filter groups created by the
GROUP BYclause?Answer:
HAVINGclause (Note:WHEREfilters rows before grouping,HAVINGfilters groups after grouping).
Which aggregate function in SQL ignores
NULLvalues except when used asCOUNT(*)?Answer:
COUNT(),SUM(),AVG(),MIN(),MAX()(all ignoreNULLexceptCOUNT(*))
Which key command is used to give permissions to database users?
Answer:
GRANT(DCL Command)
Which keyword is used to remove duplicate values from a SQL
SELECTquery result?Answer:
DISTINCT
What type of JOIN returns all records when there is a match in either left or right table?
Answer:
FULL OUTER JOIN
In an Entity-Relationship (ER) Diagram, a Weak Entity Set is represented by:
Answer: Double Rectangle
In an ER Diagram, a Multivalued Attribute is represented by a:
Answer: Double Ellipse
Which constraint prevents
NULLvalues from being inserted into a column?Answer:
NOT NULLconstraint
Which TCL command creates a point within a transaction to which you can later roll back?
Answer:
SAVEPOINT
In Relational Algebra, which operator is used for the Projection operation (selecting specific columns)?
Answer: Pi ($\pi$) operator
In Relational Algebra, which operator is used for the Selection operation (filtering rows based on conditions)?
Answer: Sigma ($\sigma$) operator
Which locking protocol guarantees Serializability in transaction execution?
Answer: Two-Phase Locking (2PL) Protocol
A situation where two or more transactions are waiting indefinitely for each other to release locks is called:
Answer: Deadlock
Which normal form requires that all attributes contain atomic values only?
Answer: First Normal Form (1NF)
Which command is used to modify the structure of an existing database table (e.g., add a new column)?
Answer:
ALTER TABLE
Which SQL statement is used to insert new rows into a database table?
Answer:
INSERT INTO
In ER Modeling, a Relationship Set among three entity types is called a:
Answer: Ternary Relationship
In SQL, pattern matching using wildcard characters (
%and_) is performed using which operator?Answer:
LIKEoperator
What does the wildcard character
_(underscore) represent in a SQLLIKEcondition?Answer: Exactly one single character
What does the wildcard character
%(percent) represent in a SQLLIKEcondition?Answer: Zero or more characters
The logical structure and organization of a database is called its:
Answer: Database Schema