Skip to content

Commit f1ecc0c

Browse files
committed
WIP.
1 parent c1b4bd6 commit f1ecc0c

14 files changed

+522
-7
lines changed

content/articles/2020-01-02-schema-design-part-1.md renamed to content/articles/2024-10-08-schema-design-part-1.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
+++
22
title = "Schema Design - Part 1: Trigger-based SQL"
33
slug = "schema-design-sql"
4-
date = "2020-01-02T00:00:00-00:00"
4+
date = "2024-10-08T00:00:00-00:00"
55
tags = ["schema-design", "sql"]
66
showpagemeta = true
77
+++
@@ -17,7 +17,7 @@ TODO
1717
[earlier post](https://eric-fritz.com/articles/easy-peasy-sql-audit-tables/)
1818

1919

20-
{{< lightbox src="/images/deposition-schema.png" anchor="deposition-schema" >}}
20+
{{< lightbox src="/images/schema-design/deposition-schema.png" anchor="deposition-schema" >}}
2121

2222
TODO - After insert, update, delete on builds:
2323

content/articles/2020-01-02-schema-design-part-2.md renamed to content/articles/2024-10-08-schema-design-part-2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
+++
22
title = "Schema Design - Part 2: SQL-Based Document Store"
33
slug = "schema-design-document-store"
4-
date = "2020-01-02T00:00:00-00:00"
4+
date = "2024-10-08T00:00:00-00:00"
55
tags = ["schema-design", "sql"]
66
showpagemeta = true
77
+++
@@ -12,4 +12,4 @@ TODO
1212

1313
TODO
1414

15-
{{< lightbox src="/images/lsif-schema.png" anchor="lsif-schema" >}}
15+
{{< lightbox src="/images/schema-design/lsif-schema.png" anchor="lsif-schema" >}}

content/articles/2020-01-02-schema-design-part-3.md renamed to content/articles/2024-10-08-schema-design-part-3.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
+++
22
title = "Schema Design - Part 3: NoSQL"
33
slug = "schema-design-nosql"
4-
date = "2020-01-02T00:00:00-00:00"
4+
date = "2024-10-08T00:00:00-00:00"
55
tags = ["schema-design", "nosql"]
66
showpagemeta = true
77
+++
@@ -40,13 +40,13 @@ The following is a small set of sample data of the Manhunt DynamoDB table. It de
4040

4141
In each row of this visualization there is an emphasized **field name** along with the `value`. The field name is how the value is interpreted once it comes back from the database, despite being stored by the generic keys `PK`, `SK`, `GSI1PK`, etc. Notice that the meanings of these values are overloaded for the same column in different rows: the partition key value for row 1 is a search identifier, but in row 2 it is a contact identifier instead. Assigning application-specific meaning to these columns on a row-by-row basis is the trick for fitting your application data into a single table.
4242

43-
{{< lightbox src="/images/manhunt-schema.png" anchor="manhunt-schema" >}}
43+
{{< lightbox src="/images/schema-design/manhunt-schema.png" anchor="manhunt-schema" >}}
4444

4545
This table shows four kinds of entities: *contact* (rows 5 and 6), *contactMethod* (rows 2, 3, and 7), *search* (rows 9 and 10), and *searchAttempt* (rows 1, 4, and 8). Additional fields for each entity are not shown for brevity. A contact method row has additional un-indexed fields to denote the contact method type, the destination, the number of seconds to wait for attempting to use this method, and a enabled/disabled flag. A search row has additional un-indexed fields for the search metadata and data about the search's resolution or cancellation. A search attempt row has additional un-indexed fields for the denormalized contact method data used for the attempt, the timestamp of the attempt, and whether/how the user responded.
4646

4747
Additionally, each row has an `entityType` field (omitted here) that holds the name of the entity the row represents. This is used to ensure application consistency on queries so that a 404 can be returned when requesting a search with the id of a contact entity, instead of failing to deserialize the row into an incompatible struct. This is not strictly necessary, but is a low-cost solution to making API endpoints a bit more ergonomic in these edge cases.
4848

49-
{{< lightbox src="/images/manhunt-schema-relations.png" anchor="manhunt-schema-relations" >}}
49+
{{< lightbox src="/images/schema-design/manhunt-schema-relations.png" anchor="manhunt-schema-relations" >}}
5050

5151
Each row has a very limited number of *slots* to put values by which the row can be queried. In order to discuss which values were chosen, let's take a deeper look into row 10, along with a few of the rows that share the same field and value pairs. Row 10 represents a search entity for the contact represented by row 5. Rows 1 and 4 represent an attempt of the search.
5252

463 KB
Loading
580 KB
Loading
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
\documentclass[tikz,border=5pt]{standalone}
2+
\usepackage{xcolor}
3+
\usetikzlibrary{calc,positioning,shapes.multipart,shapes}
4+
5+
\definecolor{cA}{HTML}{646FA9}
6+
\definecolor{cB}{HTML}{49A9B4}
7+
\definecolor{cC}{HTML}{6BCD69}
8+
\definecolor{cD}{HTML}{9B9C78}
9+
\definecolor{cE}{HTML}{CBA18C}
10+
\definecolor{cF}{HTML}{C4737C}
11+
\definecolor{cG}{HTML}{DBDBDB}
12+
\definecolor{cX}{HTML}{6A0DAD}
13+
14+
\begin{document}
15+
\tikzset{basic/.style={
16+
draw,
17+
rectangle split,
18+
rectangle split parts=2,
19+
minimum width=8cm,
20+
text width=7cm,
21+
align=left,
22+
font=\ttfamily
23+
}
24+
}
25+
\begin{tikzpicture}
26+
\node[basic, rectangle split part fill={cA,white}] (products) {
27+
products
28+
29+
\nodepart{second}
30+
name: char \hfill PK \\
31+
team\_id: integer \hfill PK \\
32+
%
33+
\color{cX}
34+
active: boolean \\
35+
active\_flagged: boolean \\
36+
deploy\_flagged: boolean \\
37+
deployed: boolean \\
38+
flagged: boolean
39+
};
40+
41+
\node[basic,rectangle split part fill={cB,white},below=2cm of products] (builds) {
42+
builds
43+
44+
\nodepart{second}
45+
version: char \hfill PK \\
46+
build\_token: char \hfill PK \\
47+
\color{cA}
48+
product\_name: char \hfill PK \\
49+
product\_team\_id: integer \hfill PK \\
50+
\color{black}
51+
phantom: boolean \\
52+
build\_datetime: timestamp \\
53+
triggered\_by\_user\_id: integer \\
54+
%
55+
\color{cX}
56+
active: boolean \\
57+
deployed: boolean \\
58+
flagged: boolean \\
59+
last\_deploy\_datetime: timestamp
60+
};
61+
62+
\node[basic,rectangle split part fill={cE,white},below=2cm of builds] (build_deployments) {
63+
build\_deployments
64+
65+
\nodepart{second}
66+
deployment\_token: char \hfill PK \\
67+
deploy\_datetime: timestamp \\
68+
\color{cB}
69+
build\_version: char \\
70+
build\_token: char \\
71+
build\_product\_name: char \\
72+
build\_team\_id: integer \\
73+
\color{black}
74+
triggered\_by\_user\_id: integer
75+
};
76+
77+
\node[basic,rectangle split part fill={cF,white},right=2cm of builds] (build_dependency_versions) {
78+
build\_dependency\_versions
79+
80+
\nodepart{second}
81+
\color{cB}
82+
build\_version: char \hfill PK \\
83+
build\_token: char \hfill PK \\
84+
build\_product\_name: char \hfill PK \\
85+
build\_team\_id: integer \hfill PK \\
86+
\color{cD}
87+
dependency\_version\_version: char \hfill PK \\
88+
dependency\_version\_name: char \hfill PK \\
89+
dependency\_version\_source: char \hfill PK
90+
};
91+
92+
\node[basic,rectangle split part fill={cD,white},right=2cm of build_dependency_versions] (dependency_versions) {
93+
dependency\_versions
94+
95+
\nodepart{second}
96+
version: char \hfill PK \\
97+
\color{cC}
98+
dependency\_name: char \hfill PK \\
99+
dependency\_source: char \hfill PK \\
100+
\color{black}
101+
lookup\_hash: char
102+
};
103+
104+
\node[basic,rectangle split part fill={cC,white},above=2cm of dependency_versions] (dependencies) {
105+
dependencies
106+
107+
\nodepart{second}
108+
name: char \hfill PK \\
109+
source: char \hfill PK \\
110+
lookup\_hash: char \\
111+
%
112+
\color{cX}
113+
flagged: boolean
114+
};
115+
116+
\node[basic,rectangle split part fill={cG,white},below=2cm of dependency_versions] (dependency_version_flags) {
117+
dependency\_version\_flags
118+
119+
\nodepart{second}
120+
depencency\_version\_flag\_id: integer \hfill PK \\
121+
description: char \\
122+
apply\_globally: boolean \\
123+
flag\_datetime: timestamp \\
124+
dependency\_version\_flag\_id: integer \\
125+
\color{cD}
126+
dependency\_version\_version: char \\
127+
dependency\_version\_name: char \\
128+
dependency\_version\_source: char \\
129+
\color{black}
130+
team\_id: integer \\
131+
reported\_by\_user\_id: integer
132+
};
133+
134+
135+
\draw[-latex] ([yshift=0pt]$(builds.north)$) -- ([yshift=0pt]$(products.south)$);
136+
\draw[-latex] ([yshift=0pt]$(build_deployments.north)$) -- ([yshift=0pt]$(builds.south)$);
137+
\draw[-latex] ([yshift=0pt]$(build_dependency_versions.west)$) -- ([yshift=0pt]$(builds.east)$);
138+
\draw[-latex] ([yshift=0pt]$(build_dependency_versions.east)$) -- ([yshift=0pt]$(dependency_versions.west)$);
139+
\draw[-latex] ([yshift=0pt]$(dependency_version_flags.north)$) -- ([yshift=0pt]$(dependency_versions.south)$);
140+
\draw[-latex] ([yshift=0pt]$(dependency_versions.north)$) -- ([yshift=0pt]$(dependencies.south)$);
141+
\end{tikzpicture}
142+
\end{document}

0 commit comments

Comments
 (0)