File notes/lectures_notes.md changed (mode: 100644) (index 043625d..56a1c9a) |
... |
... |
It's easier to move things around early in the conception. |
297 |
297 |
|
|
298 |
298 |
## Characteristics of the Database Approach |
## Characteristics of the Database Approach |
299 |
299 |
|
|
300 |
|
#. A database is more than just data: it also contains a complete description of the structure and constraints. ⇒ We have Data & Meta-data (or self-describing data). |
|
|
300 |
|
#. A database is more than just data: it also contains a complete description of the structure and constraints. ⇒ We have Data & Meta-data (we can also have self-describing data, where meta-data and data are interleaved). |
301 |
301 |
#. Data-abstraction: DBMS provides a conceptual representation, and hides implementation details. |
#. Data-abstraction: DBMS provides a conceptual representation, and hides implementation details. |
302 |
302 |
#. Program-data independence: changing the database doesn't require to change the DBMS. Compare with changing a custom data-type in a program. |
#. Program-data independence: changing the database doesn't require to change the DBMS. Compare with changing a custom data-type in a program. |
303 |
303 |
#. Program-operation independence: an operation has an interface (or signature) and an implementation (or method) |
#. Program-operation independence: an operation has an interface (or signature) and an implementation (or method) |
|
... |
... |
Solution +.# |
346 |
346 |
|
|
347 |
347 |
Solution +.# |
Solution +.# |
348 |
348 |
|
|
349 |
|
: The data is the information we want to store, the meta-data is its organization, how we are going to store it. |
|
|
349 |
|
: The data is the information we want to store, the meta-data is its organization, how we are going to store it. Meta-data is information about the data, but of no use on its own. |
350 |
350 |
|
|
351 |
351 |
Solution +.# |
Solution +.# |
352 |
352 |
|
|
353 |
|
: No, data and programs are indepent. But actually, this is true only if the model doesn't change: shifting to a "less structured model", e.g., one of the NoSQL models, can require to change the DBMS. |
|
|
353 |
|
: Normally no, data and programs are indepent. But actually, this is true only if the model doesn't change: shifting to a "less structured model", e.g., one of the NoSQL models, can require to change the DBMS. |
354 |
354 |
|
|
355 |
355 |
Solution +.# |
Solution +.# |
356 |
356 |
|
|
|
... |
... |
Solution +.# |
362 |
362 |
|
|
363 |
363 |
Solution +.# |
Solution +.# |
364 |
364 |
|
|
365 |
|
: We can use the same program for various data. Because wo don't want to re-write a new DBMS every time we change the data we use! |
|
|
365 |
|
: The application should not be sensible to the "internals" of the definition and organization of the data. It matters because having this independance means that changing the data will not require to change the programs. |
366 |
366 |
|
|
367 |
367 |
## Problems {-} |
## Problems {-} |
368 |
368 |
|
|
|
... |
... |
Problem (A database catalog for a campus) +.#campus |
404 |
404 |
Solution to @problem:campus |
Solution to @problem:campus |
405 |
405 |
~ |
~ |
406 |
406 |
|
|
407 |
|
The database catalog should be similar to the following: |
|
408 |
|
|
|
409 |
|
**RELATIONS** |
|
410 |
|
|
|
411 |
|
| Relation\_name | No\_of\_columns | |
|
412 |
|
--- | --- |
|
413 |
|
`BUILDING` | 3 |
|
414 |
|
`ROOM` | 3 |
|
415 |
|
`PROF` | 4 |
|
416 |
|
|
|
417 |
|
**COLUMNS** |
|
418 |
|
|
|
419 |
|
| Column\_name | Data\_type | Belongs\_to\_relation | |
|
420 |
|
| --- | --- | --- |
|
421 |
|
Building\_Name | Character(30) | `Building` |
|
422 |
|
GPSLat | Decimal(9,6) | `Building` |
|
423 |
|
GPSLon | Decimal(9,6) | `Building` |
|
424 |
|
Building\_Name | Character(30) | `ROOM` |
|
425 |
|
Room\_Number | Integer(1) | `ROOM` |
|
426 |
|
Floor | Integer (1) | `ROOM` |
|
427 |
|
Prof\_Name | Character (30) | `PROF` |
|
428 |
|
Phone | Integer (10) | `PROF` |
|
429 |
|
Email | Character (30) | `PROF` |
|
430 |
|
Room\_Number | Integer (1) | `PROF` |
|
431 |
|
|
|
|
407 |
|
@problem:campus -- Solution to Q. -.# |
|
408 |
|
~ |
|
409 |
|
|
|
410 |
|
The database catalog should be similar to the following: |
|
411 |
|
|
|
412 |
|
<!-- Bug with table --> |
|
413 |
|
|
|
414 |
|
**RELATIONS** |
|
415 |
|
|
|
416 |
|
| Relation\_name | No\_of\_columns | |
|
417 |
|
--- | --- |
|
418 |
|
`BUILDING` | 3 |
|
419 |
|
`ROOM` | 3 |
|
420 |
|
`PROF` | 4 |
|
421 |
|
|
|
422 |
|
**COLUMNS** |
|
423 |
|
|
|
424 |
|
| Column\_name | Data\_type | Belongs\_to\_relation | |
|
425 |
|
| --- | --- | --- |
|
426 |
|
Building\_Name | Character(30) | `Building` |
|
427 |
|
GPSLat | Decimal(9,6) | `Building` |
|
428 |
|
GPSLon | Decimal(9,6) | `Building` |
|
429 |
|
Building\_Name | Character(30) | `ROOM` |
|
430 |
|
Room\_Number | Integer(1) | `ROOM` |
|
431 |
|
Floor | Integer (1) | `ROOM` |
|
432 |
|
Prof\_Name | Character (30) | `PROF` |
|
433 |
|
Phone | Integer (10) | `PROF` |
|
434 |
|
Email | Character (30) | `PROF` |
|
435 |
|
Room\_Number | Integer (1) | `PROF` |
|
436 |
|
|
|
437 |
|
@problem:campus -- Solution to Q. -.# |
|
438 |
|
~ |
|
439 |
|
|
432 |
440 |
For the data, you could have: |
For the data, you could have: |
|
441 |
|
|
|
442 |
|
- For the `BUILDING` file, we could have: |
433 |
443 |
|
|
434 |
|
`(Allgood Hall, 33.47520, -82.02503)`, `(Institut Galilé, 48.959001, 2.339999)` |
|
435 |
|
`(Allgood Hall, 128, 1)`, `(Institut Galilé, 205, 3)`, `(Allgood Hall, 228, 2)` |
|
436 |
|
`(Aubert, 839401, dae@ipn.net, 128)`, (`Mazza, 938130, Dm@fai.net, 205)` |
|
|
444 |
|
`(Allgood Hall, 33.47520, -82.02503)`, |
|
445 |
|
`(Institut Galilé, 48.959001, 2.339999)` |
|
446 |
|
|
|
447 |
|
- For the `ROOM` file, we could have: |
|
448 |
|
|
|
449 |
|
`(Allgood Hall, 128, 1)`, |
|
450 |
|
`(Institut Galilé, 205, 3)`, |
|
451 |
|
`(Allgood Hall, 228, 2)` |
|
452 |
|
|
|
453 |
|
- For the `PROF` file, we could have: |
|
454 |
|
|
|
455 |
|
`(Aubert, 839401, dae@ipn.net, 128)`, |
|
456 |
|
(`Mazza, 938130, Dm@fai.net, 205)` |
|
457 |
|
|
|
458 |
|
@problem:campus -- Solution to Q. -.# |
|
459 |
|
~ |
437 |
460 |
|
|
438 |
461 |
If everything we knew about the campus came from that database, then |
If everything we knew about the campus came from that database, then |
439 |
462 |
|
|
|
... |
... |
Solution to @problem:campus |
442 |
465 |
#. No, we could not get the office hours of a professor. |
#. No, we could not get the office hours of a professor. |
443 |
466 |
#. Yes, we could list all the professors whose offices are in the same building. |
#. Yes, we could list all the professors whose offices are in the same building. |
444 |
467 |
#. Yes, we could list all the rooms. |
#. Yes, we could list all the rooms. |
445 |
|
#. If a new professor arrives, and has to share his office with another professor, we would not have to revise our database catalog (it is fine for two professor to have the same room number, in our model). |
|
|
468 |
|
#. If a new professor arrives, and has to share his office with another professor, we would not have to revise our database catalog (it is fine for two professor to have the same room number, in our model). |
446 |
469 |
#. Yes, we could list which professors are at the same floor. |
#. Yes, we could list which professors are at the same floor. |
447 |
470 |
#. No, we could not tell which professor has the highest evaluations. |
#. No, we could not tell which professor has the highest evaluations. |
448 |
471 |
|
|
449 |
|
|
|
450 |
472 |
# The Relational Model |
# The Relational Model |
451 |
473 |
|
|
452 |
474 |
## Resources {-} |
## Resources {-} |
|
... |
... |
You will install the [MySQL](https://www.mysql.com/) DataBase Managment System, |
1735 |
1757 |
Below are the instruction to install MySQL Community Edition on Windows 10, and MariaDB on Linux-based distribution, but both are developped for every major operating system (Mac OS, Windows, Debian, Ubuntu, etc.): feel free to pick one or the other, it won't really make a difference in this course (up to some minor aspects). MySQL is more common, MariaDB is growing, both are released under [GNU General Public License](https://www.gnu.org/licenses/licenses.html#GPL), well-documented and free of charge for their "community" versions. |
Below are the instruction to install MySQL Community Edition on Windows 10, and MariaDB on Linux-based distribution, but both are developped for every major operating system (Mac OS, Windows, Debian, Ubuntu, etc.): feel free to pick one or the other, it won't really make a difference in this course (up to some minor aspects). MySQL is more common, MariaDB is growing, both are released under [GNU General Public License](https://www.gnu.org/licenses/licenses.html#GPL), well-documented and free of charge for their "community" versions. |
1736 |
1758 |
|
|
1737 |
1759 |
It is perfectly acceptable to install MySQL or MariaDB on a virtual machine for this class. |
It is perfectly acceptable to install MySQL or MariaDB on a virtual machine for this class. |
1738 |
|
Remember that at <http://spots.augusta.edu/tschultz/resources/SWAvailable.html>, you can have access to [VMware](https://www.vmware.com/) and Windows licences, and that using [Virtual Box](https://www.virtualbox.org/wiki/Downloads) should also work fine. |
|
|
1760 |
|
Remember that using your [on the hub](https://onthehub.com/) account, you should ave access to [VMware](https://www.vmware.com/) and Windows licences, and that using [Virtual Box](https://www.virtualbox.org/wiki/Downloads) should also work fine. |
1739 |
1761 |
Once this step is completed, or if MySQL or MariaDB is already installed on your computer, go to the next step. |
Once this step is completed, or if MySQL or MariaDB is already installed on your computer, go to the next step. |
1740 |
1762 |
|
|
1741 |
1763 |
I tried to give precise and up-to-date instructions below, follow them carefully, read the messages displayed on your screen, make sure a step was correctly executed before moving to the next one, and everything should be all right. |
I tried to give precise and up-to-date instructions below, follow them carefully, read the messages displayed on your screen, make sure a step was correctly executed before moving to the next one, and everything should be all right. |
|
... |
... |
The following links could be useful: |
1757 |
1779 |
|
|
1758 |
1780 |
> Windows (x86, 32-bit), MSI Installer XXX YYY (mysql-installer-web-community-XXX.msi) |
> Windows (x86, 32-bit), MSI Installer XXX YYY (mysql-installer-web-community-XXX.msi) |
1759 |
1781 |
|
|
1760 |
|
where XXX is a number version (e.g., 8.0.11), and YYY is the size of the file (e.g., 15.8M). On the next page, click on the (somewhat hidden) "No thanks, just start my download." button. |
|
|
1782 |
|
where XXX is a number version (e.g., 8.0.13.0.), and YYY is the size of the file (e.g., 16.3M). On the next page, click on the (somewhat hidden) "No thanks, just start my download." button. |
1761 |
1783 |
#. Save the "mysql-installer-web-community-XXX.msi" file, and open it. If there is an updated version of the installer available, agree to download it. Accept the license term. |
#. Save the "mysql-installer-web-community-XXX.msi" file, and open it. If there is an updated version of the installer available, agree to download it. Accept the license term. |
1762 |
1784 |
#. We will now install the various components needed for this class, leaving all the choices by defaults. This means that you need to do the following: |
#. We will now install the various components needed for this class, leaving all the choices by defaults. This means that you need to do the following: |
1763 |
1785 |
#. Leave the first option on "Developer Default" and click on "Next" |
#. Leave the first option on "Developer Default" and click on "Next" |
|
... |
... |
Using four tools: Relations, Attributes, Primary Keys, Foreign Keys. |
3518 |
3540 |
#. Merged Relation Approach: If both participations are total, just merge them. Primary key = just pick one, and add a `NOT NULL` constraint on the other. |
#. Merged Relation Approach: If both participations are total, just merge them. Primary key = just pick one, and add a `NOT NULL` constraint on the other. |
3519 |
3541 |
#. Cross-Reference or Relationship Relation Approach: Create a lookup table with two (or more!) foreign keys, pick one of them (or the one on the N side, or both if $M:N$, or all if $n$-ary) as the primary key. |
#. Cross-Reference or Relationship Relation Approach: Create a lookup table with two (or more!) foreign keys, pick one of them (or the one on the N side, or both if $M:N$, or all if $n$-ary) as the primary key. |
3520 |
3542 |
|
|
3521 |
|
**Bogue: + Propagate option? Cascade, most of the time: weak entity type, lookup tables, etc.** |
|
|
3543 |
|
**Bug: + Propagate option? Cascade, most of the time: weak entity type, lookup tables, etc.** |
3522 |
3544 |
|
|
3523 |
3545 |
 |
 |
3524 |
3546 |
|
|