# Database System Concepts - Notes 2

> This article is currently an experimental machine translation and may contain errors. If anything is unclear, please refer to [original Chinese version](<https://blog.wendain.ing/posts/db-note-2/>). I am continuously working to improve the translation.

Textbook: Database System Concepts

Referenced blogs:

- [Kisechan's Blog](https://blog.kisechan.space/2025/notes-database-2/)
- [Database Notes | 独角恋歌](https://revival-of-hope.github.io/p/数据库笔记/)

Coverage: Textbook Chapter 6-7, roughly the E-R diagrams and database design parts

# Chapter 6 Database Design Using the E-R Model

## E-R Model

The **Entity-Relationship Model** (Entity-Relationship / E-R Model) is a semantic modeling approach: it describes real-world things with meaning / semantics at its core.

### Some Concepts

- **Entity**: an object/thing in the real world that can be distinguished from other objects/things;
- **Attribute**: describes the properties or characteristics of an entity; each attribute of an entity has a value;
- **Entity set**: a collection of entities of the same type or nature;
- **Relationship**: an association among multiple entities;
- **Relationship set**: a set of *relationships* of the same kind.

For example:

- `Student` is an **entity set**;
- Each student can be distinguished by student ID, so each student is an **entity**;
- A specific student, such as `(ID=10001, name='Alice')`, is an **entity**;
- Business relationships between objects: for example, there is a `takes` relationship between `student` and `course`, and this is a **relationship set**;
- `takes` $\neq$ a specific course enrollment, but rather the set of "the class of relationships where students take courses"; a specific relationship within it, such as student `Alice` taking `CS61A`, is a **relationship**.

### Attributes

- **Simple attribute**: cannot be divided into smaller attributes, e.g. `StudentID`
- **Composite attribute**: divisible, composed of other attributes, e.g. `Address`

```mermaid
graph TD
    Student --> StudentID
    Student --> Name
    Student --> Age
    Student --> Address

    Name --> FirstName
    Name --> LastName

    Address --> Province
    Address --> City
    Address --> Street

    Street --> StreetName
    Street --> StreetNumber
```

- **Single-valued attribute**: an attribute that can only take a single value for a specific entity
- **Multivalued attribute**: the opposite
- **Derived attribute**: the value of this attribute can be computed / derived from other attributes

You can look at this E-R Diagram to understand these definitions:

```mermaid
erDiagram
    STUDENT {
        string StudentID PK "学号 (单值属性)"
        string Name "姓名 (单值属性)"
        date BirthDate "出生日期 (单值属性)"
        string PhoneNumber "联系电话 (多值属性)"
        int Age "年龄 (派生属性，可由出生日期计算得到)"
    }
```

> [!TIP]
>
> Mermaid can represent a series of UML diagrams; for example, the source code of the mermaid diagram above is:
>
> ```-mermaid
> erDiagram
>     STUDENT {
>         string StudentID PK "学号 (单值属性)"
>         string Name "姓名 (单值属性)"
>         date BirthDate "出生日期 (单值属性)"
>         string PhoneNumber "联系电话 (多值属性)"
>         int Age "年龄 (派生属性，可由出生日期计算得到)"
>     }
> ```

### Mapping Cardinality

- **Mapping cardinality**: the **number** of entities that an entity can be associated with simultaneously through a relationship set. There are four common types of mapping cardinality:

    - **One-to-one**: one A corresponds to at most one B, and one B corresponds to at most one A. For example, "person" and "ID card number".
    - **One-to-many**: one A can correspond to multiple Bs, but one B corresponds to at most one A. For example, "department" and "student".
    - **Many-to-one**: a one-to-many viewed from the reverse direction. For example, "student" and "department".
    - **Many-to-many**: one A can correspond to multiple Bs, and one B can also correspond to multiple As. For example, "student" and "course".

    <img src="https://image.wendaining.top/image-20260427171746591.png" alt="" style="zoom:50%;" />

    > **In an E-R diagram, the arrow points to the "one" side**

- **Participation constraint**: whether entities in an entity set **must** participate in a certain relationship set:

    - **Total participation**: every entity in the entity set participates in **at least** one relationship in the relationship set;
    - **Partial participation**: only some entities in the entity set participate in the relationships of the relationship set.
    - If every student is required to belong to a department after enrollment, then Student has **total participation** in belongs_to.
    - If some teachers do not participate in any research projects for the time being, then Teacher may have **partial participation** in participates_in_project.

### Drawing

|   Graphical Symbol   |      Meaning      |                Description                |
| :----------: | :----------------: | :------------------------------------: |
|   **Rectangle**   |       Entity set       |  Represents an entity set, such as Student, Course  |
|  **Double rectangle**  |      Weak entity set      |       Has no primary key and depends on other entities for existence       |
|   **Ellipse**   |        Attribute        |          Represents an attribute of an entity or relationship          |
|  **Double ellipse**  |      Multivalued attribute      | An entity may have multiple values for this attribute (e.g. phone) |
| **Dashed ellipse** |      Derived attribute      |     Can be computed from other attributes (e.g. age)     |
|   **Diamond**   |       Relationship set       |       Represents a relationship between two or more entities       |
|   **Line**   | Connecting line for attributes or relationships |      Connects attributes and entities, or entities and relationships      |
|   **Double line**   |      Total participation      |         Indicates that the entity participates in a relationship         |

<img src="https://image.wendaining.top/image-20260427172024309.png" alt="E-R diagram for a university enterprise." style="zoom:50%;" />

## Complex Constraints

Describing constraints graphically can only express:

- Arrows pointing to the "one" side 2
- Double lines indicating **total participation**

This is not precise enough. For more precise expression, a more complex constraint notation is introduced:

```text
l..h
```

where:

- `l` is the minimum cardinality, i.e. **how many relationships must be participated in at least**, which actually corresponds to the **participation constraint**;
- `h` is the maximum cardinality, i.e. **how many relationships can be participated in at most**, which actually corresponds to the **mapping cardinality**;
- `*` means no upper limit.

![Cardinality limits on relationship sets.](https://image.wendaining.top/image-20260427193237439.png)

That is:

- One `instructor` can advise $[0, \infin]$ `student`s
- One `student` must have, and has exactly one, `advisor`

To summarize:

```text
1..*
```

is **total participation**,

```text
0..*
```

is **partial participation**.

### Constraints in Ternary Relationships

Suppose a relationship involves three entity sets, for example:

```text
student -- project -- instructor
```

meaning: a certain student is advised by a certain teacher in a certain project.

**For ternary relationships, at most one arrow is allowed**, e.g. written as `(student, project) -> instructor`.

Because there would be ambiguity otherwise.

## Primary Key

Here we understand what a primary key is from the perspective of E-R diagrams.

**Primary key of an entity set**: a set of attributes sufficient to distinguish entities.

**Primary key of a relationship set**: to distinguish different relationships within a relationship set, the primary keys of the entity sets participating in the relationship are used.

For example:

There is a relationship set `advisor(instructor, student)`

- where `instructor(ID, name)`
- `student(ID, name)`
- A specific `advisor`: `(instructor.ID = 22222, student.ID = 10001)`

The superkey of this relationship set can be `(instructor.ID, student.ID)`

> [!TIP]
>
> Recall: **super key**
>
> A set of one or more attributes, which may contain redundant attributes.
>
> It uniquely identifies a tuple in a relation.

More generally, if a relationship set $R$ involves entity sets $E_1,E_2,\ldots,E_n$, then a superkey of $R$ can be formed by the union of the primary keys of these entity sets:

$$
\operatorname{superkey}(R)=\operatorname{primary\_key}(E_1)\cup\operatorname{primary\_key}(E_2)\cup\cdots\cup\operatorname{primary\_key}(E_n)
$$

### Choice of Primary Key for Binary Relationship Sets

For a binary relationship
$$
A \;-\; R \;-\; B
$$
how to choose the primary key of relationship set $R$ depends on the **mapping cardinality**.

In brief:

- **Many-to-many**: the union of the primary keys of both sides serves as the primary key;
- **One-to-many / many-to-one**: use the primary key of the "many" side (e.g. one department corresponds to multiple students, so naturally use the students' primary key);
- **One-to-one**: the primary key of either side works.

## Weak Entity Sets and Redundant Attributes

### What Is Redundancy

Starting from an example: the `section` in a university database, i.e. the specific class offering of a course in a certain semester.

We might design `section` like this:
$$
\text{section}(\text{course\_id},\text{sec\_id},\text{semester},\text{year})
$$
and also design a relationship set `sec_course`:
$$
\text{sec\_course}(\text{section},\text{course})
$$
We then find that:

- `section.course_id` already indicates which `course` this `section` belongs to;
- `sec_course` also indicates which `course` this `section` belongs to.

Moreover, we cannot simply delete the relationship set `sec_course`, because:

- If we delete the relationship set, the relationship between the two entity sets `section` and `course` will **no longer appear explicitly in the E-R diagram**.
- This does not conform to the goal of E-R diagrams, since the goal of an E-R diagram is to clearly display the relationships between objects.

**This is** "**redundancy**".

Solution: keep only
$$
\text{section}(\text{sec\_id},\text{semester},\text{year})
$$
and then connect `section` and `course` through `sec_course`. In this way, these attributes alone **cannot uniquely identify a** `section`.

For example, different courses may all have $(1,\text{Fall},2026)$; this is a **weak entity set**.

### Strong Entity Sets, Weak Entity Sets, Identifying Entity Sets, and Discriminators

**Strong entity set**: an entity set whose own attributes can form a primary key, for example
$$
\text{course}(\underline{\text{course\_id}},\text{title},\text{credits})
$$
then $\text{course\_id}$ uniquely identifies a course;

**Weak entity set**: the opposite. For example
$$
\text{section}(\text{sec\_id},\text{semester},\text{year})
$$
this entity set depends on a strong entity set for its existence, and `section`s can only be distinguished within a certain `course`.

**Identifying entity set**: the strong entity set that helps the weak entity set achieve unique identification.

**Discriminator**: for a weak entity set, distinguishes different weak entities within one identifying entity.

For example, for `section`, $\{\text{sec\_id},\text{semester},\text{year}\}$ is a discriminator, which can distinguish different `section`s within the same `course`.

This can be understood as:
$$
\operatorname{primary\_key}(\text{section})=\operatorname{primary\_key}(\text{course})\cup\operatorname{discriminator}(\text{section})
$$
Here, **be sure to clearly distinguish the relationships among the discriminator of a weak entity set, the primary key of the weak entity set, and the primary key of the identifying entity set of the weak entity set**.

### Identifying Relationship

**Identifying relationship**: a weak entity set is connected to its identifying entity set through a special relationship.

In terms of the example above, it is
$$
\text{sec\_course}(\text{section},\text{course})
$$
The meaning of this is to tell the **identifying entity set** of a **weak entity set**, i.e.: **weak entity identity = primary key of identifying entity + discriminator of weak entity**.

> `section` itself only knows: I am `sec_id=1, semester=Fall, year=2026`
> `sec_course` tells it: you belong to `course_id=CS101`
> Only together do we know: you are `section 1` of `CS101` in `Fall 2026`

### Representation in E-R Diagrams

<img src="https://image.wendaining.top/image-20260428112917106.png" alt="Representation of weak entity sets in E-R diagrams" style="zoom:50%;" />

- Weak entities are represented by **double rectangles**;
- Discriminators are represented by **dashed underlines**;
- Identifying relationships are represented by **double diamonds**.

### Existence Dependency of Weak Entity Sets

So-called **existence dependency**: the property that every weak entity must be associated with an identifying entity.

It can also be understood as: the weak entity set has **total participation** in the identifying relationship.

### Redundant Attributes

Returning to the [What Is Redundancy](#What-Is-Redundancy) section, we would remove this redundant attribute from the E-R diagram.

However, when implementing tables, we will still **often add this redundant attribute back**. This is because when a relationship is converted back into tables, it is uncertain.

## Converting E-R Diagrams to Relational Schemas

Here we still need to distinguish between E-R diagrams and relational schemas:

- The role of an E-R diagram is to express real-world semantics;
- Relational databases store data using relational schemas, i.e. table structures.

### Basic Idea of Conversion

> *Entity sets and relationship sets can be expressed uniformly as relation schemas.*

- Each entity set or relationship set is assigned a schema with the same name; each schema has several columns, whose names generally come from attribute names, and column names must be unique;
- However, the schemas corresponding to some relationship sets are **redundant** and do not necessarily need to be kept as tables.

### Converting Entity Sets

**Strong entity set**: directly converted into a relational schema with the same name, with all attributes kept unchanged.

Understanding: a strong entity set can exist independently in the first place, and has a primary key.

**Weak entity set**: keep two parts:

- The **primary key** of the identifying entity set,
- The weak entity set's own attributes, **especially the discriminator**.

That is, the attributes of a weak entity set:
$$
\operatorname{schema}(\text{weak entity})=\operatorname{primary\_key}(\text{identifying entity})\cup\operatorname{attributes}(\text{weak entity})
$$
and the primary key of a weak entity set:
$$
\operatorname{primary\_key}(\text{weak entity})=\operatorname{primary\_key}(\text{identifying entity})\cup\operatorname{discriminator}(\text{weak entity})
$$

### Composite Attributes

Composite attributes cannot be kept as a single column. For example, if `instructor` has a composite attribute `name`, and `name` is further divided into `first_name` and `last_name`, then when converting to a relational schema, everything is written out in full.

### Multivalued Attributes

> [!TIP]
>
> **Multivalued attribute**: an attribute that can take multiple values for a specific entity.

If entity set $E$ has a multivalued attribute $M$, then a separate relational schema $EM$ is created for it, containing:

- The primary key of entity set $E$;
- The multivalued attribute $M$ itself.

For example:

- `instructor(ID, dept, phone_number)`, where `phone_number` is a multivalued attribute;
- Then, create the relational schema `inst_phone(ID, phone_number)`
- For instance, if a certain `instructor`'s primary key is `12345` and they have two phone numbers, then this table will contain two tuples, namely `(12345, 手机号1)` and `(12345, 手机号2)`.

### Many-to-Many Relationship Sets

**A separate table must be created**.

For example, $\text{student} \;-\; \text{takes} \;-\; \text{section}$: one student can correspond to multiple `section`s, and one `section` can also correspond to multiple students.

> [!TIP]
>
> - `section` is the specific offering of a course in a certain year and semester
> - `takes` means a student enrolled in a certain `section` and may have a grade

So a relationship table is needed:
$$
\text{takes}(\underline{\text{student\_id},\text{course\_id},\text{sec\_id},\text{semester},\text{year}},\text{grade})
$$
From this we can see the general rule:
$$
\operatorname{schema}(R)=\operatorname{primary\_key}(E_1)\cup\operatorname{primary\_key}(E_2)\cup\operatorname{attributes}(R)
$$
and
$$
\operatorname{primary\_key}(R)=\operatorname{primary\_key}(E_1)\cup\operatorname{primary\_key}(E_2)
$$

### One-to-Many / Many-to-One Relationship Sets

Usually the foreign key is placed on the "many" side.

For example, $\text{instructor} \;-\; \text{inst\_dept} \;-\; \text{department}$:

- One `instructor` belongs to one `department`
- One `department` can have multiple `instructor`s
- A typical **many-to-one** relationship

There is no need to create a table $\text{inst\_dept}(\text{ID},\text{dept\_name})$; simply put `dept_id` into the `instructor` table.

The attributes of the relationship set itself are also usually placed in the table of the many side.

### One-to-One Relationship Tables

**The foreign key can be placed on either side**, but prefer placing it on the side with total participation to avoid producing `NULL`s.

### When Is a Relationship Set Schema Redundant

Mainly divided into three cases:

- If the foreign key has already been placed in the many-side table, the separate relationship table is no longer needed;
- For a one-to-one relationship, after adding the foreign key on either side, the separate relationship table can also be omitted;
- The identifying relationship of a weak entity set usually no longer gets a separate table, because the usual practice is to directly incorporate the identifying relationship into the weak entity.

## Extended E-R

1. **Specialization**: splitting more specific subclasses out of a larger class.
2. **Generalization**: abstracting a common larger class from multiple subclasses.
3. **Aggregation**: treating a relationship as a whole as a higher-level object to participate in new relationships.

### Specialization & Generalization

This is the "**inheritance**" relationship in OOP.

<img src="https://image.wendaining.top/image-20260429134328882.png" alt="Specialization and generalization" style="zoom:50%;" />

> [!NOTE]
>
> **employee** is a **person**; this is an **ISA** relationship.

#### Overlapping and Disjoint

Can an entity **belong to multiple lower-level entity sets at the same time**?

- **Overlapping**: overlap is allowed; for example, a `person` can be both an `employee` and a `student`;
- **Disjoint**: overlap is not allowed; subclasses are mutually exclusive.

#### Completeness Constraint

Must a higher-level entity **belong to at least one lower-level entity set**?

- **Total**: every higher-level entity must belong to some lower-level entity set, e.g. *All student entities must be either graduate or undergraduate*.
- **Partial**: the opposite. For example, allowing a person to be neither an employee nor a student. **Partial is the default case**.

#### How Specialization Is Converted to Relational Schemas

##### Method One

1. Create a schema for the higher-level entity set.
2. Create a schema for each lower-level entity set.
3. The schema of a lower-level entity set contains the primary key of the higher-level entity set and its own local attributes.

For example, given
$$
\text{person}(\underline{\text{ID}},\text{name},\text{street},\text{city})
$$
 and the lower-level entity set $\text{student}(\text{tot\_cred})$.

It can be converted to $\text{student}(\underline{\text{ID}},\text{tot\_cred})$.

Here `student.ID` is the primary key, and also a foreign key referencing `person.ID`.

- **Advantage**: avoids repeatedly storing higher-level attributes;
- **Disadvantage**: accessing the complete information of a lower-level entity requires joining two relations.

##### Method Two

Create a table for each entity set, containing all inherited attributes and its own attributes.

This is prone to redundancy in overlapping scenarios.

### Aggregation

Treating **a relationship set together with the entity sets it involves** as a whole as a new higher-level entity.

For example, given
$$
\text{proj\_guide}(\text{student},\text{project},\text{instructor})
$$
treat it as an **abstract entity** participating in a new relationship:
$$
\text{eval\_for}(\text{proj\_guide},\text{evaluation})
$$

#### Converting Aggregation to Relational Schemas

Create a schema containing:

- The primary key of the aggregated relationship;
- The primary keys of the associated entity sets;
- Descriptive attributes.

$$
\operatorname{schema}(\text{aggregation relationship})=\operatorname{primary\_key}(\text{aggregated relationship})\cup\operatorname{primary\_key}(\text{associated entity})\cup\operatorname{descriptive\_attributes}
$$

## E-R Design Judgments

Here I excerpt some points that I find easy to misunderstand / relatively important.

### Entity Sets vs. Relationship Sets

If a concept describes an action or fact occurring between entities, it should usually be modeled as a relationship set, for example:

- Students taking courses
- Teachers advising students
- Employees belonging to departments
- Courses offering sections

Only if the action itself needs to be managed separately, has an identity of its own, or participates in other relationships, should it be promoted to an entity set.

### Placement of Relationship Attributes

**It depends on the mapping cardinality**.

- Many-to-many relationship: place it on the relationship set, e.g. the `grade` of `takes`;
- One-to-many / many-to-one relationship: place it on the many side;
- One-to-one relationship: either side.

# Chapter 7 Relational Database Design

## Overview of Normalization

So-called "normalization":

- Given a relational schema, judge whether it is good or bad;
- If bad, how to decompose it into better relational schemas without losing information?

Typical symptoms of bad design: the same piece of information is stored redundantly when joined, leading to maintenance difficulties and data anomalies. For example, when `department` is joined with `instructor`, the former's `building` and `budget` will be repeated many times.

Three types of anomalies brought by bad design:

- **Update anomaly**: for example, to update the budget of `Comp. Sci.`, you need to update all rows with `dept_name = Comp. Sci.` in this big table; missing any one will cause inconsistency;
- **Insertion anomaly**: if you want to add a department that has no teachers yet, the teacher-related attributes in this big table would have to be a bunch of `NULL`s;
- **Deletion anomaly**: if the last teacher of a department is deleted, the department's `building` and `budget` information will disappear along with it.

### You Cannot Decompose Arbitrarily

For example, in the design just mentioned, `in_dep` is redundant, and decomposing into two tables would be fine.

However, some decompositions, when joined back, produce erroneous, spurious combinations; this is a **lossy decomposition**.

The definition of **lossless decomposition**:

Let the original relational schema be $R$, decomposed into $R_1$ and $R_2$:
$$
R = R_1 \cup R_2
$$
For a relation instance $R$ on $r$, if projecting $r$ onto $R_1$ and $R_2$ first, and then naturally joining them back, yields the original $r$, then the decomposition is lossless:
$$
\Pi_{R_1}(r) \Join \Pi_{R_2}(r) = r
$$
If joining back yields more than the original, then it is a **lossy decomposition**:
$$
r \subset \Pi_{R_1}(r) \Join \Pi_{R_2}(r)
$$
The extra part is called **spurious tuples**.

### The Task of Normalization Theory

1. Determine whether a relational schema is in good form
2. If not, decompose it into a set of relational schemas

## Functional Dependencies

### Introduction

For example, for `instructor`, once its `ID` is determined, its `name` is uniquely determined as well.

This can be written as
$$
\text{ID} \rightarrow \text{name}
$$
read as: `ID` functionally determines `name`.

### Definition

Let $R$ be a relational schema, and $\alpha$ and $\beta$ be attribute sets of $R$, i.e. $\alpha \subseteq R,\quad \beta \subseteq R$.

A functional dependency is written as
$$
\alpha \subseteq R,\quad \beta \subseteq R
$$
It holds on $R$ if and only if, for any legal relation instance $r(R)$ and any two tuples $t_1,t_2$, whenever they agree on $\alpha$, they must agree on $\beta$.

This can be understood as the left side being the domain and the right side the range, hence the name **functional dependency**.

### Functional Dependency Sets and Closure

Suppose we have such a functional dependency set:
$$
F=\{A\rightarrow B,\ B\rightarrow C\}
$$
Then we can derive $A\rightarrow C$; "deriving new dependencies from existing ones" is called **logical implication**.

The set of all functional dependencies that can be derived from $F$ is called the **closure** of $F$, denoted $F^+$.

### Functional Dependencies and Superkeys / Candidate Keys

If an attribute set $K$ can determine all attributes of relational schema $R$, then $K$ is a **superkey** of $R$.

And $K$ is a candidate key if and only if $K\rightarrow R$ and there is no proper subset $\alpha \subset K$ such that $\alpha\rightarrow R$.

### Uses of Functional Dependencies

- **Testing whether a specific relation instance is legal**: test whether it satisfies all the functional dependencies;
- **Specifying legal constraints on a relational schema**: $F \text{ holds on } R$ if and only if all legal instances on relational schema $R$ satisfy $F$.

### Trivial Functional Dependencies

$$
\alpha\rightarrow\beta \text{ is trivial if } \beta\subseteq\alpha
$$

For example
$$
(A,B)\rightarrow A
$$

## Dependency Preservation

### Using Functional Dependencies to Prove a Binary Decomposition Is Lossless

Given a functional dependency set $F$ and a binary decomposition $R=R_1\cup R_2$, it suffices to prove $R_1\cap R_2 \rightarrow R_1$ or $R_1\cap R_2 \rightarrow R_1$, i.e. it suffices to prove that at least one of these two dependencies belongs to $F^+$.

This is a **sufficient condition** for a lossless join.

### Dependency Preservation

The functional dependencies on the original relational schema can still be checked directly in each of the sub-relations after decomposition, without needing to join tables in order to check constraints.

For example, suppose the original relational schema has the functional dependency $A \rightarrow B $:

- If after decomposition there exists a sub-table containing both $A$ and $B$, then the dependency can be checked directly, i.e. dependency preservation holds;
- Otherwise, several tables need to be joined to check it.

Formal statement:

Let the original relational schema be $R$, the functional dependency set be $F$, and the decomposition yield $R_1,R_2,\ldots,R_n$; for each sub-schema $R_i$, keep only those dependencies that fall entirely within $R_i$ and can be checked on $R_i$, obtaining $F_i$; if
$$
(F_1\cup F_2\cup\cdots\cup F_n)^+=F^+
$$
then we say this decomposition preserves dependencies.

## Normal Forms

Judging:

- How to determine whether a table has redundancy
- How to ensure the decomposition is lossless
- How to ensure dependency preservation

## BCNF

Let $R$ be a relational schema, and $F$ a functional dependency set on $R$. $R$ satisfies **BCNF** with respect to $F$ if and only if: for all functional dependencies of the form $F^+$ in $\alpha \rightarrow \beta$, where $\alpha \subseteq R,\quad \beta \subseteq R$, one of the following conditions holds:

- The functional dependency is **trivial**, i.e. $\beta \subseteq \alpha$;
- $\alpha$ is a superkey of $R$, i.e. $\alpha \rightarrow R$.

Example: $\text{in\_dep}$ does not satisfy BCNF:
$$
\text{in\_dep}(\text{ID},\text{name},\text{salary},\text{dept\_name},\text{building},\text{budget})
$$
because the dependency $\text{dept\_name}\rightarrow(\text{building},\text{budget})$ is non-trivial, and at the same time $\text{dept\_name}$ is not a superkey of it.







Problems caused by not conforming to normal forms: data redundancy, anomalies in insert, delete, query, and update.

Normal forms: 1 2 3 BC 4 5 (NF); the earlier ones contain the later ones.

1NF: no tables within tables

2NF: eliminate all partial functional dependencies on the primary attributes

3NF: there exist transitive functional dependencies of non-primary attributes on the primary attributes

BCNF: list all dependencies; it is satisfied if and only if the left side of every dependency is a candidate key / there are no partial or transitive dependencies within the primary attributes

Note that 1, 2, and 3 are all related to non-primary attributes, while BCNF only concerns the interior of the primary attributes.

Decomposition: **whomever you're close to, copy yourself, and take it with you**.

1, 2, 3, and BC are all about **functional dependencies**.

4NF:
