midterm 2 flashcards

1
Q

What is a relation in the relational model?

A

A relation is a named, two-dimensional table of data with rows (tuples) and columns (attributes).

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

What are the key properties of a relation?

A
  1. Unique relation name
  2. Atomic attribute values
  3. Unique rows
  4. Unique column names
  5. Column and row order does not matter.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between an entity and a relation?

A

An entity is a conceptual representation of a real-world object, while a relation is its implementation as a table in a database.

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

How do entities in an ER diagram convert to relational tables?

A

Each entity becomes a table, attributes become columns, and the primary key of the entity becomes the table’s primary key.

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

How are composite attributes handled in relational conversion?

A

They are broken down into their simpler attributes as separate columns.

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

How are multi-valued attributes handled in relational conversion?

A

They are placed in a separate relation with a foreign key linking to the original entity.

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

How are one-to-many (1:N) relationships represented in tables?

A

The primary key of the ‘one’ side is placed as a foreign key in the ‘many’ side.

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

How are many-to-many (M:N) relationships represented in tables?

A

A new junction table is created with foreign keys referencing both entities.

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

How are weak entities represented in tables?

A

A weak entity gets its own table, with its primary key including a foreign key from its identifying strong entity.

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

What is an inner join?

A

An inner join returns only the rows where there is a match between tables.

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

What is an outer join?

A

An outer join includes unmatched rows from one or both tables (Left, Right, or Full Join).

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

What is a self-join?

A

A join where a table is joined with itself, typically using aliases.

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

How does a natural join differ from an equi-join?

A

A natural join removes duplicate columns, while an equi-join keeps all columns in the result.

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

What is a subquery?

A

A SELECT statement inside another SELECT, used to fetch values for filtering or comparison.

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

What is a scalar subquery?

A

A subquery that returns only one value and is used in single-value comparisons.

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

What operator should be used for multi-row subqueries?

A

Operators like IN, ANY, or ALL should be used for multi-row subqueries.

17
Q

What is the difference between a join and a subquery?

A

A join combines multiple tables into one result set, while a subquery provides values for conditions in another query.

18
Q

What are the types of anomalies in a database?

A
  1. Insertion Anomaly 2. Deletion Anomaly 3. Modification Anomaly.
19
Q

What is referential integrity?

A

A constraint ensuring that a foreign key must match an existing primary key in the referenced table.

20
Q

What is functional dependency?

A

A relationship where one attribute uniquely determines another, e.g., Emp_ID → Emp_Name.

21
Q

What is the goal of normalization?

A

To reduce redundancy and anomalies by structuring data into well-formed tables.

22
Q

What is First Normal Form (1NF)?

A

A table is in 1NF if it has atomic attribute values and no repeating groups.

23
Q

What is Second Normal Form (2NF)?

A

A table is in 2NF if it is in 1NF and has no partial dependencies.

24
Q

What is Third Normal Form (3NF)?

A

A table is in 3NF if it is in 2NF and has no transitive dependencies (one attribute determines another and another and another…).

25
What is Boyce-Codd Normal Form (BCNF)?
A table is in BCNF if it is in 3NF and every determinant is a candidate key.
26
What is Fourth Normal Form (4NF)?
A table is in 4NF if it is in BCNF and has no multivalued dependencies.
27
When is denormalization useful?
Denormalization is useful for improving query performance by reducing joins, but it introduces redundancy.