File notes/lectures_notes.md changed (mode: 100644) (index 30bfe9d..5558261) |
... |
... |
Solution to [%D %n (%T)](#problem:repetition) |
3389 |
3389 |
+-------+------+ |
+-------+------+ |
3390 |
3390 |
~~~ |
~~~ |
3391 |
3391 |
|
|
3392 |
|
This is an illustration of the fact that a table in sql is *not* a set, as opposed to a relation in the relation model. |
|
|
3392 |
|
This is an illustration of the fact that a table in sql is *not* a set, as opposed to a relation in the relational model. |
3393 |
3393 |
|
|
3394 |
3394 |
@problem:repetition -- Solution to Q. -.# |
@problem:repetition -- Solution to Q. -.# |
3395 |
|
~ |
|
3396 |
|
|
|
3397 |
|
The command |
|
|
3395 |
|
~ The command |
3398 |
3396 |
|
|
3399 |
3397 |
~~~{.sqlmysql} |
~~~{.sqlmysql} |
3400 |
3398 |
ALTER TABLE EXAMPLE ADD PRIMARY KEY (X); |
ALTER TABLE EXAMPLE ADD PRIMARY KEY (X); |
|
... |
... |
For binary relations, can be $1:1$, $N:1$, $M:N$ ($1$ is "at most", $M$, $N$, $O |
3794 |
3792 |
|
|
3795 |
3793 |
We indicate the ratio on the edges: |
We indicate the ratio on the edges: |
3796 |
3794 |
|
|
3797 |
|
![](fig/er/Constraint1) |
|
|
3795 |
|
![](fig/er/Constraint2) |
3798 |
3796 |
|
|
3799 |
3797 |
##### Participation constraint |
##### Participation constraint |
3800 |
3798 |
|
|
|
... |
... |
Example of Use Case |
4339 |
4337 |
|
|
4340 |
4338 |
Exercise +.# |
Exercise +.# |
4341 |
4339 |
|
|
|
4340 |
|
: Name the three high-level models we will be looking at in this class (expanding the acronyms). |
|
4341 |
|
|
|
4342 |
|
Exercise +.# |
|
4343 |
|
|
4342 |
4344 |
: What could be the decomposition of an attribute used to store an email address? When could that be useful? |
: What could be the decomposition of an attribute used to store an email address? When could that be useful? |
4343 |
4345 |
|
|
4344 |
4346 |
Exercise +.# |
Exercise +.# |
|
... |
... |
Exercise +.# |
4355 |
4357 |
|
|
4356 |
4358 |
Exercise +.# |
Exercise +.# |
4357 |
4359 |
|
|
4358 |
|
: What is the difference between an entity type and a weak entity type? |
|
|
4360 |
|
: Invent an entity type with at least one composite attribute and one atomic attribute, but no multi-valued attribute, identify a possible key attribute, and draw the entity type you obtained using the conventions we used in class. |
4359 |
4361 |
|
|
4360 |
4362 |
Exercise +.# |
Exercise +.# |
4361 |
4363 |
|
|
|
... |
... |
Exercise +.# |
4379 |
4381 |
|
|
4380 |
4382 |
Exercise +.# |
Exercise +.# |
4381 |
4383 |
|
|
|
4384 |
|
: Suppose a "PRODUCES" relationship with an attribute "Amount" exists between a "PRODUCER" entity type and a "MOVIE" entity type, with ratio $1:M$. |
|
4385 |
|
Migrate the "Amount" attribute to one of the entity and draw the resulting diagram. |
|
4386 |
|
|
|
4387 |
|
Exercise +.# |
|
4388 |
|
|
|
4389 |
|
: Express the constraints represented in the following diagram in plain English. |
|
4390 |
|
![](fig/er/KeyOpensDoor) |
|
4391 |
|
|
|
4392 |
|
Exercise +.# |
|
4393 |
|
|
4382 |
4394 |
: For the following binary relationships, suggest cardinality ratios based on the common-sense meaning of the entity types. |
: For the following binary relationships, suggest cardinality ratios based on the common-sense meaning of the entity types. |
4383 |
4395 |
|
|
4384 |
4396 |
<!-- Bug with table --> |
<!-- Bug with table --> |
|
... |
... |
Exercise +.# |
4415 |
4427 |
|
|
4416 |
4428 |
Exercise +.# |
Exercise +.# |
4417 |
4429 |
|
|
|
4430 |
|
: What is the difference between an entity type and a weak entity type? |
|
4431 |
|
|
|
4432 |
|
Exercise +.# |
|
4433 |
|
|
4418 |
4434 |
: What is a partial key? |
: What is a partial key? |
4419 |
4435 |
|
|
4420 |
4436 |
Exercise +.# |
Exercise +.# |
|
... |
... |
Exercise +.# |
4583 |
4599 |
|
|
4584 |
4600 |
Solution +.# |
Solution +.# |
4585 |
4601 |
|
|
|
4602 |
|
: **U**nified **M**odeling **L**anguage, **E**ntity **R**elationship and **E**nhanced **E**ntity–**R**elationship models. |
|
4603 |
|
|
|
4604 |
|
Solution +.# |
|
4605 |
|
|
4586 |
4606 |
: Name / extension. |
: Name / extension. |
4587 |
4607 |
To have statistics about the extensions, to sort the username by length, etc. |
To have statistics about the extensions, to sort the username by length, etc. |
4588 |
4608 |
|
|
|
... |
... |
Solution +.# |
4596 |
4616 |
|
|
4597 |
4617 |
Solution +.# |
Solution +.# |
4598 |
4618 |
|
|
4599 |
|
: There can be more than one key in the ER model. |
|
|
4619 |
|
: There can be more than one key in the ER model, but it has to be made of a single attribute, whereas a primary key can be made of multiple attributes. |
4600 |
4620 |
|
|
4601 |
4621 |
Solution +.# |
Solution +.# |
4602 |
4622 |
|
|
4603 |
|
: The weak entity type doesn't have a primary key. |
|
|
4623 |
|
: ![](fig/er/Printer) |
4604 |
4624 |
|
|
4605 |
4625 |
Solution +.# |
Solution +.# |
4606 |
4626 |
|
|
|
... |
... |
Solution +.# |
4623 |
4643 |
|
|
4624 |
4644 |
: When the cardinality is $1:N$, $1:1$ or $N:1$. |
: When the cardinality is $1:N$, $1:1$ or $N:1$. |
4625 |
4645 |
|
|
|
4646 |
|
Solution +.# |
|
4647 |
|
~ |
|
4648 |
|
|
|
4649 |
|
We could have the following: |
|
4650 |
|
|
|
4651 |
|
![](fig/er/Produces) |
|
4652 |
|
|
|
4653 |
|
|
|
4654 |
|
Solution +.# |
|
4655 |
|
|
|
4656 |
|
: A key opens only one door, and every key must open at least one door. |
|
4657 |
|
A door can be opened by multiple key, and some doors may not be opened by keys (think of doors that cannot be locked). |
|
4658 |
|
|
4626 |
4659 |
Solution +.# |
Solution +.# |
4627 |
4660 |
~ |
~ |
4628 |
4661 |
|
|
|
... |
... |
Solution +.# |
4659 |
4692 |
|
|
4660 |
4693 |
Solution +.# |
Solution +.# |
4661 |
4694 |
|
|
|
4695 |
|
: The weak entity type doesn't have a key attribute, it cannot be distinguised from the other weak entities based on a single attribute, for that we also need to know its relationship to some other entity type. |
|
4696 |
|
|
|
4697 |
|
Solution +.# |
|
4698 |
|
|
4662 |
4699 |
: For a weak entity attribute, it is the attribute that can uniquely identify weak entites that are related to the same owner entity. |
: For a weak entity attribute, it is the attribute that can uniquely identify weak entites that are related to the same owner entity. |
4663 |
4700 |
|
|
4664 |
4701 |
Solution +.# |
Solution +.# |