RDBMS Fundamentals Flashcards

What is an RDBMS? Tables, rows, columns Primary key, foreign key, composite key Constraints: NOT NULL, UNIQUE, CHECK, DEFAULT Relationships: One-to-One, One-to-Many, Many-to-Many Normalization: 1NF, 2NF, 3NF, BCNF Denormalization and its trade-offs (42 cards)

1
Q

What is an RDBMS?

A

A Relational Database Management System stores data in structured formats using tables with rows and columns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are tables in RDBMS?

A

Tables are collections of related data organized in rows and columns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a row in a table?

A

A row represents a single record or entry in a table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a column in a table?

A

A column defines a specific attribute or field in the table, such as name or age.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a primary key?

A

A primary key uniquely identifies each row in a table and cannot contain NULL values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a foreign key?

A

A foreign key links a column in one table to the primary key of another table to establish relationships.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a composite key?

A

A composite key is a combination of two or more columns used together to uniquely identify a row.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a NOT NULL constraint?

A

Ensures a column cannot have NULL values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a UNIQUE constraint?

A

Ensures all values in a column are different.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a CHECK constraint?

A

Ensures that all values in a column satisfy a specific condition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a DEFAULT constraint?

A

Provides a default value for a column when none is specified.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a One-to-One relationship?

A

Each row in Table A is linked to one and only one row in Table B.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a One-to-Many relationship?

A

A row in Table A can be linked to multiple rows in Table B.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a Many-to-Many relationship?

A

Rows in Table A can be linked to multiple rows in Table B and vice versa, usually via a join table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is normalization?

A

The process of organizing data to reduce redundancy and improve data integrity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is First Normal Form (1NF)?

A

A table is in 1NF if it contains only atomic values and each column contains values of a single type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is Second Normal Form (2NF)?

A

A table is in 2NF if it is in 1NF and all non-key attributes are fully dependent on the primary key.

18
Q

What is Third Normal Form (3NF)?

A

A table is in 3NF if it is in 2NF and all its attributes are not transitively dependent on the primary key.

19
Q

What is BCNF?

A

Boyce-Codd Normal Form is a stronger version of 3NF where every determinant is a candidate key.

20
Q

What is denormalization?

A

The process of merging normalized tables to improve read performance at the cost of redundancy.

21
Q

What are the advantages of normalization?

A

Reduces redundancy, improves data integrity, and simplifies data maintenance.

22
Q

What are the disadvantages of normalization?

A

Can result in complex queries and slower read performance due to multiple joins.

23
Q

What are the advantages of denormalization?

A

Improves query performance by reducing joins.

24
Q

What are the disadvantages of denormalization?

A

Can lead to data redundancy and update anomalies.

25
What is a best practice for defining primary keys?
Use a single, immutable, and simple column as the primary key.
26
What is a best practice for relationships?
Use foreign keys with proper indexing to maintain data integrity and performance.
27
What is a common use case for One-to-Many relationships?
A customer and their orders.
28
What is a use case for Many-to-Many relationships?
Students and courses where a student can enroll in multiple courses and vice versa.
29
What is the impact of normalization on system design?
Improves data consistency but may add query complexity and performance overhead.
30
What is the architectural implication of denormalization?
Reduces read latency in read-heavy applications but increases write complexity.
31
How does normalization affect performance?
Improves write performance and integrity but may slow down reads due to joins.
32
What tools help in debugging relational databases?
SQL log analyzers, EXPLAIN query plans, and database performance monitoring tools.
33
What is a real-world tradeoff in normalization?
Better data integrity vs. potential performance issues in large-scale reads.
34
What is a common interview question about keys?
What is the difference between a primary key and a foreign key?
35
What is a common gotcha with foreign keys?
Not indexing foreign keys can degrade join performance.
36
What’s a common issue in denormalized designs?
Increased chance of data inconsistency during updates or deletes.
37
What’s a gotcha with composite keys?
They can make foreign key references more complex and error-prone.
38
Why is 3NF preferred in most OLTP systems?
It maintains data integrity and avoids redundant updates.
39
When should you consider denormalization?
When you need to optimize for fast read access and analytics queries.
40
Can a table have multiple foreign keys?
Yes, a table can have multiple foreign keys referencing different tables.
41
What is a candidate key?
An attribute, or a set of attributes, that can uniquely identify a row in a table.
42
What is a surrogate key?
An artificial key (e.g., auto-increment ID) used as the primary key instead of a natural key.