Each new query required a new program.
Most popular model today.
Example:
Student table
Course table
Used in:
MySQL
Oracle
SQL Server
Advantage
Easy to use
Supports SQL
4. Object-Oriented Model
Stores data as objects like OOP languages.
Used for complex applications.
5. NoSQL Model
Used for large-scale and unstructured data.
Types:
Document databases
Key-value databases
Graph databases
Examples:
MongoDB
Cassandra
Short Interview Answer
“A database model defines how data is organized and related in a database. Common database models are
hierarchical, network, relational, object-oriented, and NoSQL models.”
What is a Table in RDBMS?
A table in RDBMS (Relational Database Management System) is a way of storing data in the form of
rows and columns.
Each row represents a record (one entry)
Each column represents an attribute (field of data)
Example:
Roll No Name Age
1 Rahul 20
2 Priya 21
Each row = one student record
Each column = details like name, age
Interview Answer (Best Version)
“In an RDBMS, a table is a collection of related data organized in rows and columns. Each row represents a
record, and each column represents an attribute of that record. Tables are used to store structured data and
are the basic storage unit in a relational database.”
Domain
Simple definition:
A domain defines the type, format, and allowed values for a column in a table.
Example:
Roll No Name Age
1 Rahul 20
Domains:
Roll No → only positive integers (1, 2, 3…)
Name → only text/strings (no numbers)
Age → only valid numbers (e.g., 0–120)
Real-life analogy:
Think of a form:
Age field → you cannot enter “abc”
Phone number → must be digits only
That restriction is the domain
Interview Answer (Best):
“In RDBMS, a domain is the set of permissible values that an attribute can have. It defines the type, format,
and constraints of data that can be stored in a column.”
1. Attribute (Column)
An attribute is a column in a table that represents a property of data.
Example:
Name, Age, Salary are attributes
2. Tuple (Row)
A tuple is a single row (record) in a table.
Example:
(1, Rahul, 20) → one student record
3. Relation (Table)
A relation is a table in RDBMS consisting of rows and columns.
Example:
Student table = Relation
4. Degree of a Table
Number of columns (attributes) in a table.
Example:
| Roll No | Name | Age |
→ Degree = 3
5. Cardinality
Number of rows (records) in a table.
Example:
100 students → Cardinality = 100
6. Primary Key
A column that uniquely identifies each row.
Rules:
Must be unique
Cannot be NULL
Example:
Roll No
7. Foreign Key
A column that creates a link between two tables.
Example:
Student table (Roll No)
Marks table (Roll No as foreign key)
8. Null Value
Represents missing or unknown data.
Example:
Phone number not provided
9. Schema
The structure/design of a database.
Example:
Table name, columns, data types
10. Instance
The actual data stored at a specific time.
Interview Ready Answer (Short):
“In RDBMS, data is stored in tables made of rows and columns. Columns are attributes, rows are tuples, and
tables are called relations. Other important concepts include domain (valid values), primary key (unique
identifier), and foreign key (relationship between tables).”
🔑 PRIMARY KEY (Detailed Explanation)
✔️Definition (Best Interview Answer)
A Primary Key is a column (or set of columns) in a table that uniquely identifies each record. It does not
allow duplicate values or NULL values.
✔️Key Properties
Must be unique
Cannot be NULL
Only one primary key per table (but can be composite)
Ensures entity integrity
✔️Types of Primary Key
1. Simple Primary Key
One column (e.g., Roll_No)
2. Composite Primary Key
Combination of columns
Example:
Student_ID Course_ID Marks
(Student_ID + Course_ID) together uniquely identify record
✔️Why Primary Key is important?
Avoid duplicate records
Fast data retrieval
Maintains data integrity
❓ Follow-up Questions (Primary Key)
Q1: Can a primary key be NULL?
❌ No, it cannot be NULL because it must uniquely identify every row.
Q2: Can a table have multiple primary keys?
❌ No, but it can have a composite primary key (multiple columns together).
Q3: Can primary key be changed?
✔️Yes, but it is not recommended because it affects relationships.
Q4: Is primary key always a number?
❌ No, it can be number, string, or combination—but must be unique.
🔗 FOREIGN KEY (Detailed Explanation)
✔️Definition (Best Interview Answer)
A Foreign Key is a column in one table that refers to the primary key of another table. It is used to create
a relationship between two tables.
✔️Key Properties
Can have duplicate values
Can contain NULL
Refers to a primary key in another table
Ensures referential integrity
✔️Why Foreign Key is used?
Connects two tables
Prevents invalid data entry
Maintains consistency between tables
❓ Follow-up Questions (Foreign Key)
Q1: Can foreign key accept NULL?
✔️Yes, unless restricted by NOT NULL constraint.
Q2: Can foreign key have duplicate values?
✔️Yes, many rows can refer to the same primary key.
Q3: What happens if we delete parent record?
Depends on rules:
ON DELETE CASCADE → child records also deleted
RESTRICT → deletion not allowed
SET NULL → foreign key becomes NULL
Q4: Can a foreign key exist without primary key?
❌ No, it must reference a valid primary key in another table.
🔥 PRIMARY KEY vs FOREIGN KEY (Quick Comparison)
Feature Primary Key Foreign Key
Purpose Uniquely identify record Link two tables
NULL allowed No Yes
Duplicate values No Yes
Number per table One Many
Dependency Independent Depends on Primary Key
🎯 Final Interview Answer (Ready to Speak)
“A Primary Key is a column that uniquely identifies each record in a table and does not allow NULL or
duplicate values. A Foreign Key is a column that creates a relationship between two tables by referencing the
primary key of another table. Primary key ensures entity integrity, while foreign key ensures referential
integrity.”