List of commits:
Subject Hash Author Date (UTC)
Added quiz #1 of Fall 2019, plus minor corrections. a5498523b05cb246ce58b05a8951b833a0b0e699 aubert@math.cnrs.fr 2019-08-29 16:23:07
Adding a figure for a quizz, and a possible bug to the list. 6e83297ccb9678296993e605b2f35d0b13a97523 aubert@math.cnrs.fr 2019-08-27 16:20:35
Changed the monospace font, updated instructions to install mariaDB. 3dc6162733e0a373205012869c1ee068ef3e5c91 aubert@math.cnrs.fr 2019-08-16 18:56:37
Few patches to prepare for Fall 2019. 545561b3d47dfe9bff2436f8f2b7e32572cd808a aubert@math.cnrs.fr 2019-08-07 17:12:26
Editing the cycle of design picture 9bd1c3190a71202b88011b831161cf9d6a365237 aubert@math.cnrs.fr 2019-08-07 16:13:03
Test c742ba7590d59e2941f9fa197c9d009d5c642e76 au 2019-07-31 23:56:14
Minor fix in Known bugs and contrib. 19f3adfa1f88e6d12e94868f4eab0b5838d05eb6 aubert@math.cnrs.fr 2019-07-29 20:51:14
Commit 2ed1a8532cbdae46d3feb99cf52f23f2afa144ec aubert@math.cnrs.fr 2019-07-29 19:01:36
Adding the final to the notes. 0e8848a3e67ec49bab5b767e25d6099fd218e417 aubert@math.cnrs.fr 2019-05-20 14:44:54
Added the solution to one of the problem from Exam #2. 625545a335c5dc7b7303355088a3abba999fdf40 aubert@math.cnrs.fr 2019-05-06 16:59:50
Added a solution to one of the problem of Exam #2, and added the last quiz. 4e0ee25d509412e5e455d9ad4c98f7aad8c5a354 aubert@math.cnrs.fr 2019-04-19 15:14:10
A few glitches in the first java programs patched, added the alternative version to the source. 48611244d21515269bae041dc2535b7e08fb5877 aubert@math.cnrs.fr 2019-04-04 22:05:03
patching a few glitches with the java code and the mysql code used in the demo for the first program. 0fcb73dcc60aef476899c4efea092c99dd6027db aubert@math.cnrs.fr 2019-04-04 21:55:55
Tidying up a program. dd409ab3fd6736af4b8adaac284ee101b9770f60 aubert@math.cnrs.fr 2019-04-04 19:02:21
Correcting the chapter on db programming. 484c4a6372056106bae77e48b397c1174738fc26 aubert@math.cnrs.fr 2019-04-04 18:57:50
Added solution to first problem of Exam 2. 45881a9b8ab1e5a0071b58d72362059593365d52 aubert@math.cnrs.fr 2019-04-03 18:38:48
Quick note in Java programming. 625282d4fece1f6a7a617a8c9bcf7c3c856185b3 aubert@math.cnrs.fr 2019-04-02 18:42:48
Added exam #2 0aa6788451b34cb6371fed5a0f719a4ac52cf0c8 aubert@math.cnrs.fr 2019-04-01 18:37:43
Fixing a typo. 502262b742ac86d7b3d5e95a0f9fcd7ca3a6e586 aubert@math.cnrs.fr 2019-03-22 17:35:43
Forgot one figure. 1212e57a5f2e7b2f104f432feb4dce0669cdb452 aubert@math.cnrs.fr 2019-03-22 17:32:36
Commit a5498523b05cb246ce58b05a8951b833a0b0e699 - Added quiz #1 of Fall 2019, plus minor corrections.
Author: aubert@math.cnrs.fr
Author date (UTC): 2019-08-29 16:23
Committer name: aubert@math.cnrs.fr
Committer date (UTC): 2019-08-29 16:23
Parent(s): 6e83297ccb9678296993e605b2f35d0b13a97523
Signing key:
Tree: 2f864e49cf46610980dc96e483018bfc2011748d
File Lines added Lines deleted
notes/fig/rel_mod/BILL.tex 2 2
notes/lectures_notes.md 132 40
File notes/fig/rel_mod/BILL.tex changed (mode: 100644) (index e50a937..1666204)
... ... coordinate (inter) -- (Member4 |- inter) --(Member4);
40 40 (Id2)++(-0.1,0) --++ (0, -0.6) -- ++(-7,0) -- ++(0, 2.5) (Id2)++(-0.1,0) --++ (0, -0.6) -- ++(-7,0) -- ++(0, 2.5)
41 41 coordinate (inter) -- (Sponsor1 |- inter) --(Sponsor1); coordinate (inter) -- (Sponsor1 |- inter) --(Sponsor1);
42 42
43 \draw[FK] % From REPRESENTATIVES.Role to MEMBER.Id
43 \draw[FK] % From REPRESENTATIVES.Member to MEMBER.Id
44 44 (Id2)++(0.05,0) --++ (0, -3) (Id2)++(0.05,0) --++ (0, -3)
45 coordinate (inter) -- (Role3 |- inter) --(Role3);
45 coordinate (inter) -- (Member3 |- inter) --(Member3) --++ (0, 0.1);
46 46
47 47 \end{tikzpicture} \end{tikzpicture}
48 48 \end{document} \end{document}
File notes/lectures_notes.md changed (mode: 100644) (index 3a71369..75fdc6d)
... ... Refer to the ["The cycle of design" figure](#fig:cycle).
281 281 | 2910 | 1301 | | 2910 | 1301 |
282 282 | 1302 | 1301 | | 1302 | 1301 |
283 283
284
284 Note that the structure of this database could be described as:
285
286 **RELATIONS**
287
288 | Relation Name | Number of Columns|
289 | :--- | :--- |
290 | STUDENT | 4 |
291 | COURSE | 4 |
292 | SECCTION | 5 |
293 | GRADE_REPORT | 3 |
294 | PREREQUISITE | 2 |
295
296 **COLUMNS**
297
298 | Column Name | Datatype | Belongs to relation|
299 | :---: | :--- | :--- |
300 | Name | String | STUDENT |
301 | Student_number | Integer | STUDENT |
302 | Class | String | STUDENT |
303 | Major | String | STUDENT |
304 | Course_name | String | COURSE |
305 | Course_number | Integer | COURSE |
306 | Credit_hours | Integer | COURSE |
307 | Department | String | COURSE |
308 | … | … | … |
309 | Prerequisite_number | Integer | PREREQUISITE |
310
311
285 312 ### Structure ### Structure
286 313
287 314 - Database structure and records, 5 files (=collection of records), each containing data records of the same type. **Persistent storage** - Database structure and records, 5 files (=collection of records), each containing data records of the same type. **Persistent storage**
 
... ... It's easier to move things around early in the conception.
327 354
328 355 ## Exercises {-} ## Exercises {-}
329 356
357
330 358 Exercise +.# Exercise +.#
331 359
332 : Is a pile of trash a database? Why, or why not?
360 : What is the difference between a database and the meta-data of the database?
333 361
334 362 Exercise +.# Exercise +.#
335 363
336 : Which one comes first, the physical design, the conceptual design, or the logical design?
364 : Is a pile of trash a database? Why, or why not?
337 365
338 366 Exercise +.# Exercise +.#
339 367
340 : What is the difference between a database and the meta-data of the database?
368 : Define the word "miniworld".
341 369
342 370 Exercise +.# Exercise +.#
343 371
344 : Do I have to change my DBMS if I want to change the structure of my data?
372 : Assign each of the following task to one of the "character" (administrator, client, etc.) we introduced:
373
374 <!-- Bug with table -->
375
376 | Task | Assigned to|
377 | :--- | :--- |
378 | Install a DBMS on a server. |   |
379 | Sketch the schema so that the data will not be redundant. |   |
380 | Write client-side application that uses the DBMS API.|   |
381 | Establish the purpose of the database. |   |
345 382
346 383 Exercise +.# Exercise +.#
347 384
348 : What is a virtual data? How can I access it?
385 : Expand the acronym "DBMS".
349 386
350 387 Exercise +.#nameDBMS Exercise +.#nameDBMS
351 388
 
... ... Exercise +.#
355 392
356 393 : Why do DBMS include concurrency control? : Why do DBMS include concurrency control?
357 394
395 Exercise +.#
396
397 : Do I have to change my DBMS if I want to change the structure of my data?
398
358 399 Exercise +.#programdataindependence Exercise +.#programdataindependence
359 400
360 401 : What is independence between program and data? Why does it matter? : What is independence between program and data? Why does it matter?
361 402
362 403 Exercise +.# Exercise +.#
363 404
364 : Define the word "miniworld".
405 : Name the four different kinds of action that can be performed on data.
365 406
366 407 Exercise +.# Exercise +.#
367 408
368 : Expand the acronym "DBMS".
409 : Assume that I have a file where one record corresponds to one student. Should the information about the classes a student is taking (e.g. room, instructor, code, etc.) being stored in the same file? Why, or why not?
369 410
370 411 Exercise +.# Exercise +.#
371 412
372 : Name the four different kinds of action that can be performed on data.
413 : Which one comes first, the physical design, the conceptual design, or the logical design?
373 414
374 415 Exercise +.# Exercise +.#
375 416
376 : Assume that I have a file where one record corresponds to one student. Should the information about the classes a student is taking (e.g. room, instructor, code, etc.) being stored in the same file? Why, or why not?
417 : What is a virtual data? How can I access it?
377 418
378 419
379 420 ## Solution to Exercises {-} ## Solution to Exercises {-}
380 421
381 422 Solution +.# Solution +.#
382 423
383 : No, because it lacks a logical structure.
424 : 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.
384 425
385 426 Solution +.# Solution +.#
386 427
387 : The conceptual design.
428 : No, because it lacks a logical structure.
388 429
389 430 Solution +.# Solution +.#
390 431
391 : 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.
432 : The mini-world is the part of the universe we want to represent in the database. It is supposed to be meaningful and will serve a purpose.
392 433
393 434 Solution +.# Solution +.#
394 435
395 : 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.
436 : We can have something like:
396 437
397 Solution +.#
438 <!-- Bug with table -->
398 439
399 : It is a set of information that is derived from the database but not directly stored in it. It is accessed through queries.
440 | Task | Assigned to|
441 | :--- | :--- |
442 | Install a DBMS on a server. | Administrator, IT service |
443 | Sketch the schema so that the data will not be redundant. | Designer |
444 | Write client-side application that uses the DBMS API.| Programmer, Developer |
445 | Establish the purpose of the database. | Client, business owner |
400 446
401 447 Solution +.# Solution +.#
402 448
403 : Oracle RDBMS, IBM DB2, Microsoft SQL Server, MySQL, PostgreSQL, Microsoft Access, etc., are valid answers. Are not valid "SQL", "NoSQL", "Relational Model", or such: we are asking for the names of actual softwares!
449 : Database Management System
404 450
405 451 Solution +.# Solution +.#
406 452
407 : To ensure that several users trying to update the same data will do so in a controlled manner. To avoid inconsistency.
453 : Oracle RDBMS, IBM DB2, Microsoft SQL Server, MySQL, PostgreSQL, Microsoft Access, etc., are valid answers. Are not valid "SQL", "NoSQL", "Relational Model", or such: we are asking for the names of actual softwares!
408 454
409 455 Solution +.# Solution +.#
410 456
411 : 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.
457 : Normally no, data and programs are independent. 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.
412 458
413 459 Solution +.# Solution +.#
414 460
415 : The mini-world is the part of the universe we want to represent in the database. It is supposed to be meaningfull and will serve a purpose.
461 : DBMS have concurrency control to ensure that several users trying to update the same data will do so in a controlled manner. It is to avoid inconsistency to appear in the data.
416 462
417 463 Solution +.# Solution +.#
418 464
419 : Database Management System
465 : The application should not be sensible to the "internals" of the definition and organization of the data. It matters because having this independence means that changing the data will not require to change the programs.
420 466
421 467 Solution +.# Solution +.#
422 468
 
... ... Solution +.#
431 477
432 478 : If we were to store all the information about the classes in the student records, then we would have to store it as many time as its number of students! It is better to store it in a different file, and then to "link" the two files, to avoid redundancy. : If we were to store all the information about the classes in the student records, then we would have to store it as many time as its number of students! It is better to store it in a different file, and then to "link" the two files, to avoid redundancy.
433 479
480 Solution +.#
481
482 : The conceptual design.
483
484 Solution +.#
485
486 : It is a set of information that is derived from the database but not directly stored in it. It is accessed through queries. For instance, we can infer the age of a person if their date of birth is in the database, but strictly speaking the age is not an information stored in the database.
487
488
489
490
491
492
434 493 ## Problems {-} ## Problems {-}
435 494
436 495 Problem (A database catalog for a campus) +.#campus Problem (A database catalog for a campus) +.#campus
 
... ... Solution to @problem:campus
489 548 **COLUMNS** **COLUMNS**
490 549
491 550 | Column\_name | Data\_type | Belongs\_to\_relation | | Column\_name | Data\_type | Belongs\_to\_relation |
492 | --- | --- | ---
493 Building\_Name | Character(30) | `Building`
494 GPSLat | Decimal(9,6) | `Building`
495 GPSLon | Decimal(9,6) | `Building`
496 Building\_Name | Character(30) | `ROOM`
497 Room\_Number | Integer(1) | `ROOM`
498 Floor | Integer (1) | `ROOM`
499 Prof\_Name | Character (30) | `PROF`
500 Phone | Integer (10) | `PROF`
501 Email | Character (30) | `PROF`
502 Room\_Number | Integer (1) | `PROF`
551 | --- | --- | --- |
552 Building\_Name | Character(30) | `Building` |
553 GPSLat | Decimal(9,6) | `Building`|
554 GPSLon | Decimal(9,6) | `Building` |
555 Building\_Name | Character(30) | `ROOM`|
556 Room\_Number | Integer(1) | `ROOM`|
557 Floor | Integer (1) | `ROOM` |
558 Prof\_Name | Character (30) | `PROF` |
559 Phone | Integer (10) | `PROF` |
560 Email | Character (30) | `PROF`|
561 Room\_Number | Integer (1) | `PROF`|
503 562
504 563 @problem:campus -- Solution to Q. -.# @problem:campus -- Solution to Q. -.#
505 564 ~ ~
 
... ... Room\_Number | Integer (1) | `PROF`
532 591 #. No, we could not get the office hours of a professor. #. No, we could not get the office hours of a professor.
533 592 #. 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.
534 593 #. Yes, we could list all the rooms. #. Yes, we could list all the rooms.
535 #. 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).
594 #. 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).
536 595 #. Yes, we could list which professors are at the same floor. #. Yes, we could list which professors are at the same floor.
537 596 #. No, we could not tell which professor has the highest evaluations. #. No, we could not tell which professor has the highest evaluations.
538 597
 
... ... Exercise +.#
850 909
851 910 Assuming that this is all the data we will ever have, discuss whenever $\{A, B, C, D\}$, $\{A, B\}$ and $\{B\}$ are superkeys and/or keys. Assuming that this is all the data we will ever have, discuss whenever $\{A, B, C, D\}$, $\{A, B\}$ and $\{B\}$ are superkeys and/or keys.
852 911
912 Exercise +.#
913 ~ Consider the following relation and possible state. Assuming that this is all the data we will ever have, give two superkeys, and one key, for this relation.
914
915 <!-- Bug with table -->
916 **A** | **B** | **C** | **D** |
917 --- | --- | --- | --- |
918 1 | A | Austin | `true`|
919 2 | B | Paris | `true` |
920 1 | C | Pisa | `false`|
921 2 | C | Augusta | `true`|
922 1 | B | Augusta | `true`|
923
924 Exercise +.#
925 ~ Consider the following two relations:
926
927 ![
928 BUILDING(Name (PK), Address)
929 ROOM(Code (PK), Building (FK to BUILDING.Name))
930 ](fig/rel_mod/BUILDING_ROOM)
931 \
932
933 #. Give two possible tuples for the BUILDING relation, and two possible tuples for the ROOM relation.
934 #. Based on the data you gave previously, write (in pseudo-code) one `INSERT` and one `UPDATE` instruction that would violate the integrity of your database.
935
936
853 937 ## Solution to Exercises {-} ## Solution to Exercises {-}
854 938
855 939 Solution +.# Solution +.#
 
... ... Solution +.#
892 976
893 977 Solution +.# Solution +.#
894 978
895 : Then we know that $A_2$ is the primary key of $R_2$.
979 : Then we know that $A_2$ is the primary key of $R_2$, and that $A_1$ and $A_2$ have the same domain.
896 980
897 981 Solution +.# Solution +.#
898 982
899 983 : Reading from the database, performing `UPDATE`{.sqlmysql} or `DELETE`{.sqlmysql} operations. : Reading from the database, performing `UPDATE`{.sqlmysql} or `DELETE`{.sqlmysql} operations.
900 984
985 Solution +.#
986
987 : An operation is an "atomic action" that can be performed on the database (adding an element, updating a value, removing an element, etc.). A transaction is a series of such operations, and the assumption is that, even if it can be made of operations that, taken individually, could violate a constraint, the overall transaction will leave the database in a consistent state.
988
901 989 Solution +.# Solution +.#
902 990 ~ ~
903 991
904 992 a) COMPUTER has for arity $4$, and OS has for arity $3$. a) COMPUTER has for arity $4$, and OS has for arity $3$.
905 993 b) ("Linda McFather", 32, 2017, "Purism"), and ("Debian", "Stable", "amd64") b) ("Linda McFather", 32, 2017, "Purism"), and ("Debian", "Stable", "amd64")
906 994
907
908 Solution +.#
909
910 : An operation is an "atomic action" that can be performed on the database (adding an element, updating a value, removing an element, etc.). A transaction is a series of such operations, and the assumption is that, even if it can be made of operations that, taken individually, could violate a constraint, an operation will leave the database in a consistent state.
911
912 995 Solution +.# Solution +.#
913 996
914 997 : An operation whose execution in isolation would result in the violation of a constraint can either a) be "restricted" (i.e., not executed), b) result in a propagation (i.e., the tuples that would violate a constraint are updated or deleted accordingly), or c) result in some values in tuples that would violate a constraint to be set to a default value, or the `NULL` value (this last option works only if the constraint violated is the referential entity constraint). : An operation whose execution in isolation would result in the violation of a constraint can either a) be "restricted" (i.e., not executed), b) result in a propagation (i.e., the tuples that would violate a constraint are updated or deleted accordingly), or c) result in some values in tuples that would violate a constraint to be set to a default value, or the `NULL` value (this last option works only if the constraint violated is the referential entity constraint).
 
... ... Solution +.#
948 1031 - $\{A, B\}$ is a superkey **and** a key, as neither $\{A\}$ nor $\{B\}$ are keys. - $\{A, B\}$ is a superkey **and** a key, as neither $\{A\}$ nor $\{B\}$ are keys.
949 1032 - $\{A\}$ is not a key, and not a superkey: multiple tuples have the value $1$. - $\{A\}$ is not a key, and not a superkey: multiple tuples have the value $1$.
950 1033
1034 Solution +.#
1035 ~ Possible superkeys are $\{A, B, C, D\}$, $\{A, B, C\}$, $\{A, C, D\}$, $\{B, C, D\}$, $\{A, B\}$, $\{B, C\}$, . The possible keys are $\{A, B\}$ $\{A, C\}$, and $\{B, C\}$.
1036
1037 Solution +.#
1038 ~
1039
1040 #. For the BUILDING relation: <"A.H", "123 Main St.">, <"U.H.", "123 Main St.">. For the ROOM relation: <12, "A.H.">, <15, "A.H.">.
1041 #. `INSERT <"A.H.", NULL>` would violate the requirement not to have two tuples with the same value for the primary key in the BUILDING relation. `UPDATE ROOM with CODE = 12 to Building = "G.C.C."` would create an entry referencing a name in the BUILDING relation that does not exist.
1042
951 1043 ## Problems {-} ## Problems {-}
952 1044
953 1045 Problem (Finding candidate key in a CLASS relation) +.#candidatekeyinclass Problem (Finding candidate key in a CLASS relation) +.#candidatekeyinclass
 
... ... Problem (Relational model for bills) +.#rel_model_bills
1007 1099
1008 1100 Solution to @problem:cinema Solution to @problem:cinema
1009 1101
1010 ~
1102 ~ A possible solution is:
1011 1103
1012 1104 ![STAR(Id (PK), Name, BirthDate) ![STAR(Id (PK), Name, BirthDate)
1013 1105 MOVIE(Id (PK), Title, Year, Length, Genre) MOVIE(Id (PK), Title, Year, Length, Genre)
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/caubert/CSCI_3410

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/caubert/CSCI_3410

Clone this repository using git:
git clone git://git.rocketgit.com/user/caubert/CSCI_3410

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main