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: docs/databases.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ There are many databases of many types.
68
68
69
69
A database could be a single file called `heroes.db`, managed with code in a very efficient way. An example would be SQLite, more about that in a bit.
70
70
71
-

71
+

72
72
73
73
### A server database
74
74
@@ -80,11 +80,11 @@ In this case, your code would talk to this server application instead of reading
80
80
81
81
The database could be located in a different server/machine:
82
82
83
-

83
+

84
84
85
85
Or the database could be located in the same server/machine:
86
86
87
-

87
+

88
88
89
89
The most important aspect of these types of databases is that **your code doesn't read or modify** the files containing the data directly.
90
90
@@ -98,7 +98,7 @@ In some cases, the database could even be a group of server applications running
98
98
99
99
In this case, your code would talk to one or more of these server applications running on different machines.
100
100
101
-

101
+

102
102
103
103
Most of the databases that work as server applications also support multiple servers in one way or another.
104
104
@@ -257,7 +257,7 @@ For example, the table for the teams has the ID `1` for the team `Preventers` an
257
257
258
258
As these **primary key** IDs can uniquely identify each row on the table for teams, we can now go to the table for heroes and refer to those IDs in the table for teams.
So, in the table for heroes, we use the `team_id` column to define a relationship to the *foreign* table for teams. Each value in the `team_id` column on the table with heroes will be the same value as the `id` column of one row in the table with teams.
Copy file name to clipboardExpand all lines: docs/db-to-code.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -279,7 +279,7 @@ For example this **Relation** or table:
279
279
280
280
***Mapper**: this comes from Math, when there's something that can convert from some set of things to another, that's called a "**mapping function**". That's where the **Mapper** comes from.
281
281
282
-

282
+

283
283
284
284
We could also write a **mapping function** in Python that converts from the *set of lowercase letters* to the *set of uppercase letters*, like this:
In this example of tables above 👆, it would return all the heroes, because every hero has a `team_id`, so every hero can be joined with the `team` table:
299
299
@@ -318,7 +318,7 @@ But in the database that we are working with in the code above, **Spider-Boy** d
318
318
319
319
So there's no way to join the **Spider-Boy** row with some row in the `team` table:
Copy file name to clipboardExpand all lines: docs/tutorial/indexes.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,35 +34,35 @@ Imagine a **dictionary**, a book with definitions of words. 📔 ...not a Python
34
34
35
35
Let's say that you want to **find a word**, for example the word "**database**". You take the dictionary, and open it somewhere, for example in the middle. Maybe you see some definitions of words that start with `m`, like `manual`, so you conclude that you are in the letter `m` in the dictionary.
So, you know you have to search in the dictionary **before** the point you currently are. You still don't know where the word `database` is, because you don't know exactly where the letter `d` is in the dictionary, but you know that **it is not after** that point, you can now **discard the right half** of the dictionary in your search.
Next, you **open the dictionary again**, but only taking into account the **half of the dictionary** that can contain the word you want, the **left part of the dictionary**. You open it in the middle of that left part and now you arrive maybe at the letter `f`.
You know that `d` from `database` comes before `f`. So it has to be **before** that. But now you know that `database`**is not after** that point, and you can discard the dictionary from that point onward.
Now you have a **small section of dictionary** to search (only a **quarter** of dictionary can have your word). You take that **quarter** of the pages at the start of the dictionary that can contain your word, and open it in the middle of that section. Maybe you arrive at the letter `c`.
You repeat this process **a few more times**, and you finally arrive at the letter `d`, you continue with the same process in that section for the letter `d` and you finally **find the word**`database`. 🎉
You had to open the dictionary a few times, maybe **5 or 10**. That's actually **very little work** compared to what it could have been.
68
68
@@ -96,7 +96,7 @@ Open the index, and after **5 or 10 steps**, quickly find the topic "**database*
96
96
97
97
Now you know that you need to find "**page 253**". But by looking at the closed book you still don't know where that page is, so you have to **find that page**. To find it, you can do the same process again, but this time, instead of searching for a **topic** in the **index**, you are searching for a **page number** in the **entire book**. And after **5 or 10 more steps**, you find the page 253 in Chapter 5.
After this, even though this book is not a dictionary and has some particular content, you were able to **find the section** in the book that talks about a "**database**" in a **few steps** (say 10 or 20, instead of reading all the 500 pages).
Notice that each hero can only have **one** connection. But each team can receive **many** connections. In particular, the team **Preventers** has two heroes.
63
63
@@ -83,7 +83,7 @@ As this will represent the **hero-team-link**, let's call the table `heroteamlin
0 commit comments