You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/20-concepts/01-relational.md
+25-30Lines changed: 25 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,6 @@
1
-
---
2
-
title: Relational Theory
3
-
date: 2024-08-20
4
-
authors:
5
-
- name: Dimitri Yatsenko
6
-
---
1
+
# Relational Model
7
2
8
-
# Origins of Relational Theory
3
+
##Origins of Relational Theory
9
4
10
5
Relations are a key concept in mathematics, representing how different elements from one set are connected to elements of another set. When two sets are of elements are related to each other, this forms a *second-order* or *binary* relation. Higher orders are also possible: third, fourth, and $n^{th}$ order relations.
11
6
@@ -58,7 +53,7 @@ Cantor's set theory introduced the idea that relations could be seen as subsets
58
53
[Georg Cantor](https://en.wikipedia.org/wiki/Georg_Cantor) (1845-1918) reframed relations in the context of Set Theory
59
54
```
60
55
61
-
# Mathematical Foundations
56
+
##Mathematical Foundations
62
57
Relational theory is not just a mathematical curiosity; it is a powerful tool that underpins many important concepts in mathematics and computer science. The ability to describe and analyze how different objects are connected is fundamental to many areas of study.
63
58
64
59
One of the most important applications of relational theory is in the concept of **functions**. A function is a specific type of relation where each element in the domain (the first set) is associated with exactly one element in the codomain (the second set). Functions are essential in nearly every area of mathematics, from calculus to linear algebra.
@@ -77,7 +72,7 @@ In first-order logic, predicates represent relations, and the logical statements
77
72
The equivalence between relational theory and first-order logic was notably formalized by Alfred Tarski in the 1930s.
78
73
Tarski demonstrated that every relation can be described by a formula in first-order logic, establishing a profound connection between these mathematical frameworks that has since underpinned much of modern theoretical computer science and logic.
79
74
80
-
# Relational Algebra and Calculus
75
+
##Relational Algebra and Calculus
81
76
82
77
**Relational algebra** is a set of operations that can be used to transform relations in a formal way.
83
78
It provides the foundation for querying relational databases, allowing us to combine, modify, and retrieve data stored in tables (relations).
@@ -130,7 +125,7 @@ The query notation of the SQL programming language combines concepts from both r
130
125
However, DataJoint's query language is based purely on relational algebra.
131
126
:::
132
127
133
-
# Relational Database Model
128
+
##Relational Database Model
134
129
The **relational data model** is the brainchild of the British-American mathematician and engineer [Edgar F. Codd.](https://amturing.acm.org/award_winners/codd_1000892.cfm), earning him the prestigeous Turing Award in 1981.
135
130
136
131
Working at IBM, Codd explored the possibility of translating the mathematic rigor of relational theory into powerful system for large-scale data management and operation [@10.1145/362384.362685].
@@ -178,23 +173,23 @@ Practical database programmers speak of tables and rows while theoretical data m
178
173
|**Tuple**|**Record** or **Row**| A single element of a relation, containing a value for each attribute. |
179
174
:::
180
175
181
-
# Three Views of the Relational Model
176
+
##Three Views of the Relational Model
182
177
183
178
The relational data model, while powerful, offers considerable flexibility that can be both a blessing and a curse. This flexibility has led to the development of three distinct conceptual frameworks for understanding and applying relational databases. While these approaches share the same underlying syntax (tables, primary keys, foreign keys, etc.), they provide fundamentally different **semantics** that lead to distinct approaches to database design, data manipulation, and query formation.
184
179
185
-
## The Mathematical View: Predicate Calculus and Functional Dependencies
180
+
###The Mathematical View: Predicate Calculus and Functional Dependencies
186
181
187
182
The **mathematical view** of the relational model, championed by Edgar F. Codd, is rooted in **predicate calculus** and **set theory**. This approach treats relations as mathematical predicates—statements about variables that can be determined to be true or false.
188
183
189
-
### Core Definitions
184
+
####Core Definitions
190
185
191
186
**Relation as Predicate**: A table (relation) represents a logical predicate; it contains the complete set of all facts (propositions) that make the predicate true.
192
187
193
188
**Tuple as Proposition**: Each row (tuple) is a specific set of attribute values that asserts a true proposition for the predicate. For example, if a table's predicate is "Employee $x$ works on Project $y$," the row (Alice, P1) asserts: "Employee Alice works on Project P1."
194
189
195
190
**Functional Dependencies**: The core concept is the functional dependency: attribute `A` functionally determines attribute `B` (written `A → B`) if knowing the value of `A` allows you to determine the unique value of `B`.
196
191
197
-
### Design Philosophy
192
+
####Design Philosophy
198
193
199
194
The mathematical approach frames database design as deciding **which predicates should become base relations (stored tables)** so that:
200
195
- All other valid true propositions can be **most easily and efficiently derived** through relational operations
@@ -203,15 +198,15 @@ The mathematical approach frames database design as deciding **which predicates
203
198
204
199
**Normalization Principle**: "Every non-key attribute must depend on the key, the whole key, and nothing but the key."
205
200
206
-
### Characteristics
201
+
####Characteristics
207
202
-**Abstract**: Reasons about predicates and functional dependencies, not real-world entities
208
203
-**Mathematical**: Provides formal, rigorous definitions and proofs
209
204
-**Attribute-centric**: Focuses on relationships between attributes
210
205
-**Prescriptive**: Provides clear rules (normal forms) to check compliance
211
206
212
-
## The Entity-Relationship View: Domain Modeling
207
+
###The Entity-Relationship View: Domain Modeling
213
208
214
-
The **entity-relationship view**, introduced by Peter Chen in 1976, revolutionized how we think about database design by shifting from abstract mathematical concepts to concrete domain modeling.
209
+
The **entity-relationship view**, introduced by Peter Chen in 1976, revolutionized how we think about database design by shifting from abstract mathematical concepts to concrete domain modeling: @10.1145/320434.320440, @10.1007/978-3-642-59412-0_17
215
210
216
211
```{figure} ../images/PChen.jpeg
217
212
:name: Peter Chen
@@ -220,21 +215,21 @@ The **entity-relationship view**, introduced by Peter Chen in 1976, revolutioniz
220
215
Peter Chen, born in 1943, Taiwanese-American computer scientist, inventor of the Entity-Relationship Model.
221
216
```
222
217
223
-
### Core Definitions
218
+
####Core Definitions
224
219
225
220
**Entity Set**: An unordered collection of identifiable items (entities) that share the same attributes and are distinguished by a primary key.
226
221
227
222
**Relationship Set**: A collection of associations that link entities from different entity sets, defined by referential constraints (foreign keys).
228
223
229
224
**Entity Type**: A well-defined category of things in the domain (e.g., Student, Course, Department).
230
225
231
-
### Design Philosophy
226
+
####Design Philosophy
232
227
233
228
The entity-relationship approach frames database design as identifying **what entity types exist** in the domain and **how they relate to each other**.
234
229
235
230
**Entity Normalization Principle**: "Each table represents exactly one well-defined entity type, identified by the table's primary key. All non-key attributes must describe that entity type directly, completely, and non-optionally."
236
231
237
-
### Characteristics
232
+
####Characteristics
238
233
-**Concrete**: Starts with recognizable entities in the domain
239
234
-**Intuitive**: Maps to how people naturally think about their domain
240
235
-**Entity-centric**: Focuses on identifying entity types and their properties
@@ -259,11 +254,11 @@ erDiagram
259
254
Entity-relationship diagram in [Crow's Foot notation](https://mermaid.js.org/syntax/entityRelationshipDiagram.html).
260
255
:::
261
256
262
-
## The Entity-Workflow View: Temporal and Operational Modeling
257
+
###The Entity-Workflow View: Temporal and Operational Modeling
263
258
264
259
The **entity-workflow view**, pioneered by DataJoint, extends entity normalization with a sequential dimension: the **Entity-Workflow Model**. While traditional ERM focuses on **what entities exist**, DataJoint emphasizes **when and how entities are created** through workflow execution.
265
260
266
-
### Core Definitions
261
+
####Core Definitions
267
262
268
263
**Workflow Entity**: An entity that is created at a specific step in a workflow, representing an artifact of workflow execution.
269
264
@@ -273,13 +268,13 @@ The **entity-workflow view**, pioneered by DataJoint, extends entity normalizati
273
268
274
269
**Directed Acyclic Graph (DAG)**: The schema structure that represents valid workflow execution sequences, prohibiting circular dependencies.
275
270
276
-
### Design Philosophy
271
+
####Design Philosophy
277
272
278
273
The entity-workflow approach frames database design as mapping **workflow steps to tables** and ensuring **temporal coherence** in entity creation.
279
274
280
275
**Workflow Normalization Principle**: "Every table represents an entity type that is created at a specific step in a workflow, and all attributes describe that entity as it exists at that workflow step."
281
276
282
-
### Characteristics
277
+
####Characteristics
283
278
-**Temporal**: Views entities as artifacts created by operations
284
279
-**Operational**: Focuses on workflow sequence and dependencies
285
280
-**Workflow-centric**: Emphasizes when/how entities are created
@@ -291,11 +286,11 @@ The entity-workflow approach frames database design as mapping **workflow steps
291
286
DataJoint diagram for the same design
292
287
```
293
288
294
-
## Semantic Differences and Convergence
289
+
###Semantic Differences and Convergence
295
290
296
-
While all three views use the same underlying syntax (tables, primary keys, foreign keys), they provide fundamentally different **semantics**:
291
+
While all three views rely on the same underlying constructs (tables, data types, primary keys, foreign keys), they provide fundamentally different **semantics**:
0 commit comments