Skip to content

Commit e9b5f90

Browse files
improve the Unique Identifier section
1 parent 0ada498 commit e9b5f90

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

book/30-schema-design/025-uuid.ipynb

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,25 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Using UUIDs\n",
7+
"# Unique Identifiers\n",
8+
"\n",
9+
"It is often becomes necessary to assign unique identifiers to entities in a database as *surragate primary key* values. There are many schemes for generating such identifiers.\n",
10+
"One of the most common approaches in simple cases is an autoincrementing integer field. Most SQL databases support this with built-in features such as `AUTO_INCREMENT` in MySQL or `SERIAL` in PostgreSQL. It's simple and fast.\n",
11+
"\n",
12+
"However, autoincrementing ids are not suitable for large distributed systems such as social media platforms (e.g. Instagram). It may be helpful to generate unique identifiers that do not require a database connection or a round-trip to the server.\n",
13+
"\n",
14+
"\n",
15+
"Reading: \n",
16+
"* Various Unique Identifiers: https://osamadev.medium.com/understanding-unique-identifiers-uid-uuid-guid-cuid-and-nano-id-3ef2d104ecdf\n",
17+
"* UUIDs: https://en.wikipedia.org/wiki/Universally_unique_identifier\n",
18+
"* NANOID: https://github.com/ai-sdk/nanoid-python\n",
19+
"* NANOID Collision Calculator:https://zelark.github.io/nano-id-cc/\n",
20+
"* Sharding IDs at Instagram: https://instagram-engineering.com/sharding-ids-at-instagram-1cf5a71e5a5c\n",
21+
"* ULID: https://medium.com/@juniooor/ulid-universally-unique-lexicographically-sortable-identifier-5544e3391660\n",
22+
"* ULID: https://github.com/ulid/spec\n",
23+
"\n",
24+
"\n",
25+
"## Universally Unique Identifiers (UUIDs)\n",
826
"\n",
927
"Universally Unique Identifiers (UUIDs) provide a convenient mechanism for generating unique identifiers for entities inside an information system. The use of UUIDs is standardized by as RFC 4122.\n",
1028
"\n",
@@ -26,7 +44,7 @@
2644
},
2745
{
2846
"cell_type": "code",
29-
"execution_count": 3,
47+
"execution_count": null,
3048
"metadata": {},
3149
"outputs": [
3250
{
@@ -1764,7 +1782,7 @@
17641782
],
17651783
"metadata": {
17661784
"kernelspec": {
1767-
"display_name": "Python 3 (ipykernel)",
1785+
"display_name": "base",
17681786
"language": "python",
17691787
"name": "python3"
17701788
},
@@ -1778,7 +1796,7 @@
17781796
"name": "python",
17791797
"nbconvert_exporter": "python",
17801798
"pygments_lexer": "ipython3",
1781-
"version": "3.9.17"
1799+
"version": "3.13.2"
17821800
}
17831801
},
17841802
"nbformat": 4,

0 commit comments

Comments
 (0)