Database notes for interview
Database notes for interview
1. What is a Database?
Answer:
A database is an organized collection of data that can be easily accessed, managed, and
updated. Databases are used to store information electronically and are managed by
Database Management Systems (DBMS), such as MySQL, Oracle, SQL Server, and
PostgreSQL.
Answer:
3. What is SQL?
Answer:
SQL (Structured Query Language) is a standard programming language used to manage and
manipulate relational databases. It is used for querying, inserting, updating, and deleting
data.
Answer:
Answer:
A Primary Key uniquely identifies each record in a table. It must contain unique values and cannot be NULL.
Each table can have only one primary key.
Answer:
A Foreign Key is a field in a table that creates a relationship between two tables. It refers to the Primary Key of
another table and helps maintain referential integrity.
7. What is Normalization?
Answer:
Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity.
Common normal forms include:
Answer:
A JOIN clause is used to combine rows from two or more tables based on a related column. Types of JOINs:
9. What is an Index?
Answer:
An Index improves the speed of data retrieval in a database. It is similar to an index in a book and helps the
DBMS find rows more efficiently.
Answer:
A View is a virtual table based on the result set of an SQL statement. It does not store the data itself but provides a
way to look at data from one or more tables.
Answer:
ACID properties ensure reliable processing of database transactions:
Answer:
Answer:
A Stored Procedure is a precompiled collection of SQL statements that can be executed repeatedly. It helps in code
reusability and improves performance.
Answer:
🔍 How It Helps
Query: SELECT * FROM Employees WHERE Department = 'IT';
HR Row 1, Row 5
IT Row 2, Row 4
❌ Caution
- Indexes increase storage requirements
🔍 What is Normalization?
Normalization is the process of organizing data in a database to reduce redundancy and
improve data integrity. It involves dividing large tables into smaller ones and defining
relationships between them.
✅ Goals of Normalization
Eliminate redundant data (repetition of data).
No repeating groups.
Example:
StudentID Name Courses
1 Alice Math, Physics
2 Bob Chemistry
👉 Not in 1NF (multi-valued attribute Courses)
Converted to 1NF:
Split to 2NF:
Student_Course Table:
StudentID Course
1 Math
1 Physics
Course_Instructor Table:
Course Instructor
Math Mr. Rahim
Physics Mr. Karim
Split to 3NF:
Student Table:
Department Table:
Department Dept_Location
CS Building A
Math Building B