File notes/00_sum.md changed (mode: 100644) (index 6603c01..fdc1184) |
... |
... |
On top of the [references](references) and of the "resources" listed at the begi |
131 |
131 |
- Check that solution of exercises numbering match exercise numbering. |
- Check that solution of exercises numbering match exercise numbering. |
132 |
132 |
- numbering of Question in exercises is faulty: 1 numbering for all exercises! |
- numbering of Question in exercises is faulty: 1 numbering for all exercises! |
133 |
133 |
- Style for html page: add libertine font? https://dev.aurelienpierre.com/utiliser-la-fonte-linux-libertine-pour-le-web/ |
- Style for html page: add libertine font? https://dev.aurelienpierre.com/utiliser-la-fonte-linux-libertine-pour-le-web/ |
|
134 |
|
- How to extract something from textbook: export page to pdf, open with inkscape, select interresting part, cut, paste in new document, CTRL+shift+D, "resize page to drawing or selection", export as a pdf. |
134 |
135 |
|
|
135 |
136 |
# Introduction |
# Introduction |
136 |
137 |
|
|
|
... |
... |
Problem (A database catalog for a campus) +.#campus |
327 |
328 |
|
|
328 |
329 |
We want to define a `CAMPUS` database organized into three files as follows: |
We want to define a `CAMPUS` database organized into three files as follows: |
329 |
330 |
|
|
330 |
|
- A `BUILDING` file storing the name and GPS coordinates of each building. |
|
331 |
|
- A `ROOM` file storing the building, number and floor of each room. |
|
332 |
|
- A `PROF` file storing the name, phone number, email and room number where the office is located for each professor. |
|
|
331 |
|
- A `BUILDING` file storing the name and GPS coordinates of each building. |
|
332 |
|
- A `ROOM` file storing the building, number and floor of each room. |
|
333 |
|
- A `PROF` file storing the name, phone number, email and room number where the office is located for each professor. |
333 |
334 |
|
|
334 |
335 |
@problem:campus -- Question -.# |
@problem:campus -- Question -.# |
335 |
336 |
~ Look at [@Textbook6, Figure 1.3], or [@Textbook7, Figure 1.3] to understand how to write a database catalog. It is made of two part: a table containing the relations' name and their number of columns, and a table containing the columns' name, their data type, and the relation to which they belong. |
~ Look at [@Textbook6, Figure 1.3], or [@Textbook7, Figure 1.3] to understand how to write a database catalog. It is made of two part: a table containing the relations' name and their number of columns, and a table containing the columns' name, their data type, and the relation to which they belong. |
|
... |
... |
TICKETS(Id (PK), ShowTimeId (FK to SHOWTIME.Id), Price) |
766 |
767 |
](img/rel_mod/CINEMA.svg){ width=100% } |
](img/rel_mod/CINEMA.svg){ width=100% } |
767 |
768 |
\ |
\ |
768 |
769 |
|
|
769 |
|
# SQL |
|
|
770 |
|
# The SQL Programming Language |
770 |
771 |
|
|
771 |
772 |
## Resources {-} |
## Resources {-} |
772 |
773 |
|
|
|
... |
... |
SPECIAL-ITEM(Name (P), Quest (FK to QUEST.Name)) |
3113 |
3114 |
](img/rel_mod/RPG.svg){ width=100% } |
](img/rel_mod/RPG.svg){ width=100% } |
3114 |
3115 |
\ |
\ |
3115 |
3116 |
|
|
3116 |
|
# Design |
|
|
3117 |
|
# Designing a Good Database |
3117 |
3118 |
|
|
3118 |
|
## Resources |
|
|
3119 |
|
## Resources {-} |
3119 |
3120 |
|
|
|
3121 |
|
This part of the lecture covers significantly more material than the other, hence we give the details of the references below: |
3120 |
3122 |
|
|
3121 |
|
- E.-R. models: Chapter 7 |
|
3122 |
|
- E.-R. to relational model: 9.1 |
|
3123 |
|
- Normalization: 15 |
|
3124 |
|
- UML: not so much in the textbook, but you can look at 7.8 and 10.3 |
|
|
3123 |
|
- E.-R. models: [@Textbook6, Ch. 7] or [@Textbook7, Ch. 3] |
|
3124 |
|
- The E.-R. to Relational model: [@Textbook6, Ch. 9.1] or [@Textbook7, Ch. 9.1] |
|
3125 |
|
- Normalization: [@Textbook6, Ch. 7] or [@Textbook7, Ch. 3] |
|
3126 |
|
- UML: not so much in the textbook, but you can look at [@Textbook6, Ch. 7.8, 10.3] or [@Textbook7, Ch. 3.8]. |
3125 |
3127 |
|
|
3126 |
3128 |
## Interest for High-Level Design |
## Interest for High-Level Design |
3127 |
3129 |
|
|
3128 |
|
Show mistakes and limitations of previous relational models studies. |
|
3129 |
|
We could go back and forth between Relational models (Logical level) and SQL implementations (Physical level). |
|
3130 |
|
We will use multiple models: |
|
|
3130 |
|
Previous relational models have mistakes and limitations: |
|
3131 |
|
|
|
3132 |
|
- What if a hurricane is over more than one state? |
|
3133 |
|
- What if an insurance covers more than one car, more than one driver? |
|
3134 |
|
- Changing the code "on the fly", as we did for the `Lecture` and `Grade` tables, is difficult and error-prone. |
|
3135 |
|
|
|
3136 |
|
We could go back and forth between relational models (logical level) and SQL implementations (physical level), but we will use even more high-level tools: |
3131 |
3137 |
|
|
3132 |
3138 |
- Entity Relationship Models (ER, static: DB) |
- Entity Relationship Models (ER, static: DB) |
3133 |
3139 |
- Unified Modelling Diagrams (UML, dynamic: DB + software) |
- Unified Modelling Diagrams (UML, dynamic: DB + software) |
3134 |
|
- Enhanced Entity Relationship Models (adds operations to ER) |
|
|
3140 |
|
- Enhanced Entity Relationship Models (EER, adds operations to ER) |
3135 |
3141 |
|
|
3136 |
3142 |
---------------------- ------------ --------- ---------- |
---------------------- ------------ --------- ---------- |
3137 |
3143 |
Feature Conceptual Logical Physical |
Feature Conceptual Logical Physical |
|
... |
... |
We will use multiple models: |
3145 |
3151 |
Column Data types ✔ |
Column Data types ✔ |
3146 |
3152 |
---------------------- ------------ --------- ---------- |
---------------------- ------------ --------- ---------- |
3147 |
3153 |
|
|
3148 |
|
Remember that in Relational models, relations were representing entities and relationships, here the distinction is made in this table (entity vs relationship). |
|
3149 |
|
|
|
3150 |
|
Remember that this model and Relational models are DBMS independant, and the CS is at the border between humans and computers. |
|
3151 |
|
Cf. Figure 7.1 (3.1 in 7th Edition) for the "parrallel journey" of operations. |
|
3152 |
|
|
|
3153 |
|
 |
|
|
3154 |
|
Remember that in relational models, relations were representing entities (`Student`) and relationships (`Majors_In`), here the distinction is made in this table (entity vs relationship). |
3154 |
3155 |
|
|
3155 |
|
Topics to come include: |
|
|
3156 |
|
Remember that a model is supposed to be DBMS independant, and that computer science is at the border between humans and computers. |
|
3157 |
|
Cf. [@Textbook6, Figure 7.1] or [@Textbook7, Figure 3.1] for the "parrallel journey" of operations: |
3156 |
3158 |
|
|
3157 |
|
- Definitions of entities and relationships |
|
3158 |
|
- Recursive relationships |
|
3159 |
|
- Weak entity types (give example of dependant) |
|
3160 |
|
- Relations with arity greater than 2 (example of a transaction with 3 parties: book, customer, library, and notion of attribute of that relation) |
|
3161 |
|
- E.R. to Relational model mapping (algorithm, and places where a choice is needed) |
|
3162 |
|
- Guidelines for good models |
|
3163 |
|
- Functional dependecies |
|
3164 |
|
- Normal form (a seal, and a purification process) |
|
|
3159 |
|
 |
|
3160 |
|
\ |
3165 |
3161 |
|
|
3166 |
|
Take the time to introduce future topics + to give exam back. |
|
|
3162 |
|
Introduce topics to come. |
3167 |
3163 |
|
|
3168 |
3164 |
--- |
--- |
3169 |
3165 |
|
|
3170 |
3166 |
|
|
3171 |
3167 |
## Entity-Relationship (ER) Model |
## Entity-Relationship (ER) Model |
3172 |
3168 |
|
|
3173 |
|
Data = entity, relationships, attributes |
|
|
3169 |
|
Data is organized into entity, relationships and attributes. |
3174 |
3170 |
|
|
3175 |
3171 |
### Enties and attributes |
### Enties and attributes |
3176 |
3172 |
|
|
|
... |
... |
Entity A : |
3188 |
3184 |
|
|
3189 |
3185 |
Attributes can be |
Attributes can be |
3190 |
3186 |
|
|
3191 |
|
- composite (divided in smaller parts) or simple (atomic) |
|
3192 |
|
- single-valued or multi-valued |
|
3193 |
|
- stored vs derived |
|
3194 |
|
- nested! |
|
|
3187 |
|
- Composite (divided in smaller parts) or simple (atomic) |
|
3188 |
|
- Single-valued or multi-valued |
|
3189 |
|
- Stored vs derived |
|
3190 |
|
- Nested! |
3195 |
3191 |
|
|
3196 |
3192 |
\{…\} = multi-valued |
\{…\} = multi-valued |
3197 |
3193 |
|
|
3198 |
3194 |
(…) = complex |
(…) = complex |
3199 |
3195 |
|
|
3200 |
|
\{Address(Street, Number, Apt, City, State, ZIP)\} |
|
|
3196 |
|
For instance, one could store multiple address using the "schema" `{Address(Street, Number, Apt, City, State, ZIP)}`. |
3201 |
3197 |
|
|
3202 |
3198 |
### Entity types and key attributes |
### Entity types and key attributes |
3203 |
3199 |
|
|
3204 |
|
- Entity = actual thing |
|
|
3200 |
|
Some vocabulary: |
|
3201 |
|
|
|
3202 |
|
- Entity = actual thing (individuel) |
3205 |
3203 |
- Entity type = collection of entities with the same attributes |
- Entity type = collection of entities with the same attributes |
3206 |
3204 |
- Entity set (or collection) = collection of all entities of a particular entity type. |
- Entity set (or collection) = collection of all entities of a particular entity type. |
3207 |
3205 |
|
|
3208 |
3206 |
#### Key attributes |
#### Key attributes |
3209 |
3207 |
|
|
3210 |
|
A key attribute is an attribute whose value is distinct for each individual in the entity set. |
|
|
3208 |
|
A key attribute is an attribute whose value is distinct for each entity in the entity set. |
3211 |
3209 |
|
|
3212 |
3210 |
- Serve to identify entity |
- Serve to identify entity |
3213 |
|
- Can be more than 1 such attribute |
|
3214 |
|
- Cannot be multiple attributes: if more than 1 attribute is needed to make a key attribute, combine them into a composite attribute and make it the key. |
|
|
3211 |
|
- Can be more than one such attribute |
|
3212 |
|
- Cannot be multiple attributes: if more than one attribute is needed to make a key attribute, combine them into a composite attribute and make it the key. |
3215 |
3213 |
- A composite attribute that is a key attribute should not still be a key attribute if we were to remove one of the attribute (similar to the minimality requirement). |
- A composite attribute that is a key attribute should not still be a key attribute if we were to remove one of the attribute (similar to the minimality requirement). |
3216 |
|
- An entity with no key is called a weak entity type (more about that later). |
|
|
3214 |
|
- An entity with no key is called a weak entity type: it is an entity that will be identified thanks to its relation to other entities, and thanks to its partial key (we will discuss this later). |
3217 |
3215 |
|
|
3218 |
3216 |
#### Drawing entity types |
#### Drawing entity types |
3219 |
3217 |
|
|
3220 |
|
- Entity = squared box |
|
3221 |
|
- Attribute = rounded box connected to a square box |
|
3222 |
|
- Composite = rounded box connected to rounded box |
|
3223 |
|
- Multivalued = double lined rounded box connected to a square box |
|
3224 |
|
- Derived = dotted line |
|
|
3218 |
|
- Entity = squared box (name in upper case) |
|
3219 |
|
- Attribute = rounded box connected to square box (name in lower case) |
|
3220 |
|
|
|
3221 |
|
| If the attribute is …, | then… | |
|
3222 |
|
| --- | --- | |
|
3223 |
|
composite | other attributes are connected to it | |
|
3224 |
|
multivalued | the box have double lines | |
|
3225 |
|
derived | the box have dotted lines | |
|
3226 |
|
a key | the name of the attribute is underlined | |
3225 |
3227 |
|
|
3226 |
3228 |
{ width=100% } |
{ width=100% } |
3227 |
3229 |
\ |
\ |
3228 |
3230 |
|
|
3229 |
|
(Yes, we do need |
|
3230 |
|
|
|
3231 |
|
{ width=100% } |
|
|
3231 |
|
{ width=100% } |
|
3232 |
|
\ |
3232 |
3233 |
|
|
3233 |
3234 |
--- |
--- |
3234 |
3235 |
|
|
|
... |
... |
Reminder: entity = actual thing, entity set = collection of entities, entity typ |
3238 |
3239 |
|
|
3239 |
3240 |
#### Vocabulary |
#### Vocabulary |
3240 |
3241 |
|
|
3241 |
|
- Relationship instance = $r_1$ associates $n$ entities $e_1$, …, $e_n$. |
|
|
3242 |
|
- Relationship = actual relation (or action) between entities ("teaches", "loves", "possesses", etc.). |
|
3243 |
|
- Relationship instance = $r_1$ associates $n$ entities $e_1$, …, $e_n$ ("Pr. X teaches CSCI YYY", "There is love between Mary and Paul", etc.) |
3242 |
3244 |
- Relationship set = collection of instances |
- Relationship set = collection of instances |
3243 |
|
- Relationship type = abstraction. |
|
|
3245 |
|
- Relationship type = abstraction ("Every course belong to one instructor", "Love is a relation between two persons", etc). |
3244 |
3246 |
|
|
3245 |
3247 |
$E_1$, … $E_n$ *participate* in R, $e_1$, …, $e_n$ *participate* in $r_1$, $n$ is the degree. |
$E_1$, … $E_n$ *participate* in R, $e_1$, …, $e_n$ *participate* in $r_1$, $n$ is the degree. |
3246 |
3248 |
|
|
|
3249 |
|
{ width=100% } |
|
3250 |
|
\ |
|
3251 |
|
|
3247 |
3252 |
Naming convention: |
Naming convention: |
3248 |
3253 |
|
|
3249 |
|
- Singular for entity types, name for entity. |
|
3250 |
|
- Verb for relationship. Avoid blurry names (not "HAS") |
|
3251 |
|
- Drawing usually read right to left, and up to down. COMPANY WORKS_FOR CITIZEN: no, pick EMPLOYS). |
|
|
3254 |
|
- Use a singular name for entity types. |
|
3255 |
|
- Use a verb for relationship. |
|
3256 |
|
- Relationship types are drawn in losanges. |
|
3257 |
|
- Drawing usually reads right to left, and up to down. |
3252 |
3258 |
|
|
3253 |
|
{ width=100% } |
|
|
3259 |
|
|
|
3260 |
|
{ width=100% } |
|
3261 |
|
\ |
3254 |
3262 |
|
|
3255 |
3263 |
|
|
3256 |
3264 |
#### Recursive and role names |
#### Recursive and role names |
3257 |
3265 |
|
|
3258 |
|
Convenient, and sometimes mandatory, to give role names: |
|
|
3266 |
|
Convenient, and sometimes mandatory, to give role names. |
|
3267 |
|
|
|
3268 |
|
If we want to stress that we are considering only one aspect of an entity (that is, a person is not only an employee, a company is not only an employer, but this aspect is crucial for the "EMPLOYS" relation): |
|
3269 |
|
|
|
3270 |
|
{ width=100% } |
|
3271 |
|
|
|
3272 |
|
We can also use it to make the "right-side" and the "left-side" of a somehow ambiguous relationship explicit: |
|
3273 |
|
|
|
3274 |
|
{ width=100% } |
|
3275 |
|
{ width=100% } |
3259 |
3276 |
|
|
3260 |
|
{ width=100% } |
|
3261 |
|
{ width=100% } |
|
|
3277 |
|
It is sometimes mandatory to do so. |
3262 |
3278 |
|
|
3263 |
|
Stress one aspect of the relationship. |
|
3264 |
3279 |
|
|
3265 |
3280 |
#### Constraints |
#### Constraints |
3266 |
3281 |
|
|
|
... |
... |
Crow's foot notation: |
3351 |
3366 |
|
|
3352 |
3367 |
<https://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow%27s_foot_notation> |
<https://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow%27s_foot_notation> |
3353 |
3368 |
|
|
3354 |
|
## Enhanced Entity–Relationship (E.E.R) Model |
|
|
3369 |
|
### Enhanced Entity–Relationship (E.E.R) Model |
3355 |
3370 |
|
|
3356 |
3371 |
Extended (or Enhanced) E.R. Models have additionaly: |
Extended (or Enhanced) E.R. Models have additionaly: |
3357 |
3372 |
|
|
|
... |
... |
Extended (or Enhanced) E.R. Models have additionaly: |
3360 |
3375 |
|
|
3361 |
3376 |
Closer to OO programming. |
Closer to OO programming. |
3362 |
3377 |
|
|
3363 |
|
## Reverse Engineering |
|
|
3378 |
|
### Reverse Engineering |
3364 |
3379 |
|
|
3365 |
3380 |
From relational models to E.R. models (sometimes needed) |
From relational models to E.R. models (sometimes needed) |
3366 |
3381 |
|
|
|
... |
... |
Can also be used for DBMS fingerprinting. |
5536 |
5551 |
|
|
5537 |
5552 |
## To Be Determined |
## To Be Determined |
5538 |
5553 |
|
|
5539 |
|
**bogue** : check SLO and add relevant topics here. |
|
|
5554 |
|
**bogue** Add topics on "Recognize professional responsibilities and make informed judgments in computing practice based on legal and ethical principles." |
5540 |
5555 |
|
|
5541 |
|
# NoSQL |
|
|
5556 |
|
# Presentation of NoSQL |
5542 |
5557 |
|
|
5543 |
5558 |
## Resources {-} |
## Resources {-} |
5544 |
5559 |
|
|