List of commits:
Subject Hash Author Date (UTC)
Various editing, fixing some of the solutions in Chapter 3 and some of the exercises in Chapter 4. 1e1d8dd576329b20aa3b7f9344aaecb9d11fc6f4 aubert@math.cnrs.fr 2019-02-22 20:22:09
Added the rest of the first exam for Fall 2019. 0d5a839282b1ae6e6c07e7b12a74ff2f0f2f3b86 aubert@math.cnrs.fr 2019-02-22 20:03:02
Adding a problem and its solution, in the SQL chapter. d5bfcbb949a6acac68156a8b37d6f8d23375b1cb aubert@math.cnrs.fr 2019-02-19 19:53:27
Adding second quiz, and fixing some exercises and problems in Chapter 3. 062c9b46fad52848efbf61e08c91103c0bae4127 aubert@math.cnrs.fr 2019-02-06 20:04:16
Clarification on SQL constraints. 70e26a02aa344cc1bf009a089623be6baac79ba7 aubert@math.cnrs.fr 2019-01-29 22:46:26
Adding some minor SQL remarks + code for HW_FACULTY. 1d1b74302d29fb63c3c2bacca30533283f720997 aubert@math.cnrs.fr 2019-01-25 17:24:16
fixing small typo. 0feeb8df61e05d6d0990120628303cf31108f100 aubert@math.cnrs.fr 2019-01-22 18:23:34
Quick fix + adding macOS install instructions. ea3063e4e9225c8ce66838c8bfddb9a34aadacf8 aubert@math.cnrs.fr 2019-01-16 15:59:38
Fixing a few typos and adding a drawing. b335800d4129c8e29763a6c1d564243d485fa51b aubert@math.cnrs.fr 2019-01-15 19:03:38
Fixing first homework 3eeb05a78235274a330c780f4f26b5fed1a01aef aubert@math.cnrs.fr 2019-01-08 19:50:29
Added content of various exam, fixed intro, added references, solutions, fixed types. a8e9d2d4856133d68d882403cde42dfcc2f5cc69 aubert@math.cnrs.fr 2019-01-07 16:47:02
Cleaning files and makefile 7605a6530505ad69042413dd995d77f1814c2f30 au 2018-12-24 14:25:31
Fixed margin for PDF, added a couple of SVG images, fixed some problems, added some code. eb83d9f07d738df7ab2515b768d6165a3b7e5ca3 au 2018-12-24 02:28:36
Working on rel_mod for Prof_Department_Extended. 2b1eff83797fbda620189f014043d648c884e887 au 2018-12-23 22:38:07
Working on FD and various figures. 8fd7f8322e70ae252596aa9cb88918ac40d5aa84 au 2018-12-23 20:25:19
Added first drawing for fd. 2a0e4fc716d91c23c81346a0e3b568f7132284c9 au 2018-12-23 05:23:29
Cleaned latex code. 1cf04e85915d24fc0208b407eb0166803b2369cf au 2018-12-23 04:27:41
Working on drawing for functional dependencies. 7dc167021630c00be25881877c0921adbc87f482 au 2018-12-23 04:20:33
Working on style for functional dependencies graph. 029c32395ba1110ad2af980e248848e0877040d7 au 2018-12-23 00:17:54
Working on template for FD. 091bb061b6fea06f440e97a4c9ac0f69b4ea1392 au 2018-12-22 20:57:00
Commit 1e1d8dd576329b20aa3b7f9344aaecb9d11fc6f4 - Various editing, fixing some of the solutions in Chapter 3 and some of the exercises in Chapter 4.
Author: aubert@math.cnrs.fr
Author date (UTC): 2019-02-22 20:22
Committer name: aubert@math.cnrs.fr
Committer date (UTC): 2019-02-22 20:22
Parent(s): 0d5a839282b1ae6e6c07e7b12a74ff2f0f2f3b86
Signer:
Signing key:
Signing status: N
Tree: d8f8fa698e61e6f5e9724171edb60793851ed66b
File Lines added Lines deleted
notes/code/sql/LECTURE.sql 6 0
notes/lectures_notes.md 32 25
File notes/code/sql/LECTURE.sql changed (mode: 100644) (index 93696b3..e062379)
... ... INSERT INTO LECTURE VALUES
15 15 ('Intro to Algebra', 'perdos', 2017, '1405'), ('Intro to Algebra', 'perdos', 2017, '1405'),
16 16 ('Intro to Cyber', 'aturing', 2017, '1234'); ('Intro to Cyber', 'aturing', 2017, '1234');
17 17
18 -- This representation can not handle the following situations:
19 -- - If multiple instructors teach the same class,
20 -- - If the lecture is taught more than once a year (either because it is taught in the Fall, Spring and Summer, or if multiple sections are offered at the same time),
21 -- - If a lecture is cross-listed, then some duplication of information will be needed.
22
23
18 24 -- Question 3 -- Question 3
19 25 ALTER TABLE GRADE ALTER TABLE GRADE
20 26 ADD COLUMN LectureCode CHAR(5), ADD COLUMN LectureCode CHAR(5),
File notes/lectures_notes.md changed (mode: 100644) (index 4bc8dc8..d33f4de)
... ... Exercise +.#explainfk
2281 2281 ~ ~
2282 2282
2283 2283 If `PkgName` is the primary key in the table `MYTABLE`, what can you tell about the number of rows returned by the following statement? If `PkgName` is the primary key in the table `MYTABLE`, what can you tell about the number of rows returned by the following statement?
2284
2284 2285 `SELECT * FROM MYTABLE WHERE PkgName = 'MySQL';`{.sqlmysql}. `SELECT * FROM MYTABLE WHERE PkgName = 'MySQL';`{.sqlmysql}.
2285 2286
2286 2287 Exercise +.# Exercise +.#
 
... ... Problem (TRAIN table and more advanced SQL coding) +.#train
2943 2944
2944 2945 @problem:train -- Question -.# @problem:train -- Question -.#
2945 2946
2946 : Write `INSERT` statements that insert one tuple of your invention in each relation.
2947 : Write `INSERT` statements that insert one tuple of your invention in each relation (without `NULL` values).
2947 2948 Your statements should respect all the constraints (including the ones we added at the previous questions) and result in actual insertions. (Remember that four digits is a valid value for an attribute with the `YEAR(4)` datatype.) Your statements should respect all the constraints (including the ones we added at the previous questions) and result in actual insertions. (Remember that four digits is a valid value for an attribute with the `YEAR(4)` datatype.)
2948 2949
2949 2950 @problem:train -- Question -.# @problem:train -- Question -.#
 
... ... Solution to [%D %n (%T)](#problem:address)
3258 3259 ~~~ ~~~
3259 3260
3260 3261 @problem:address -- Solution to Q. -.# @problem:address -- Solution to Q. -.#
3261 ~
3262 ~ We have.
3262 3263
3263 3264 ![ ![
3264 3265 NAME(FName, LName, Id(PK)) NAME(FName, LName, Id(PK))
 
... ... Solution to [%D %n (%T)](#problem:address)
3278 3279
3279 3280 @problem:address -- Solution to Q. -.# @problem:address -- Solution to Q. -.#
3280 3281
3281 : This syntax is better for "bulk insertion", since it allows to write less command, and to focus on the data to insert.
3282 : This syntax is better for "bulk insertion", since it allows to write less command, and to focus on the data to insert. However, if an error occurs, then nothing gets inserted.
3282 3283
3283 3284 @problem:address -- Solution to Q. -.# @problem:address -- Solution to Q. -.#
3284 3285
 
... ... Solution to [%D %n (%T)](#problem:repetition)
3359 3360
3360 3361 CREATE TABLE EXAMPLE( CREATE TABLE EXAMPLE(
3361 3362 X VARCHAR(15), X VARCHAR(15),
3362 Y INT);
3363 Y INT
3364 );
3363 3365 ~~~ ~~~
3364 3366
3365 3367 @problem:repetition -- Solution to Q. -.# @problem:repetition -- Solution to Q. -.#
 
... ... Solution to [%D %n (%T)](#problem:repetition)
3390 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. 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.
3391 3393
3392 3394 @problem:repetition -- Solution to Q. -.# @problem:repetition -- Solution to Q. -.#
3393 ~
3395 ~
3394 3396
3395 3397 The command The command
3396 3398
 
... ... Solution to [%D %n (%T)](#problem:repetition)
3430 3432 Solution to [%D %n (%T)](#problem:profrevisited) Solution to [%D %n (%T)](#problem:profrevisited)
3431 3433 ~ ~
3432 3434
3433 We only give the relevant code for this problem:
3435 For Question 1 and 5, we obtain:
3436
3437 ![PROF(Login (PK), Name, Department (FK to DEPARTMENT.Code))
3438 DEPARTMENT(Code (PK), Name, Head (FK to PROF.Login))
3439 LECTURE (Code (PK), Year (PK), Name, Instructor (FK to PROF.Login)
3440 STUDENT(Login (PK), Name, Registered, Major (FK to DEPARTMENT.Code))
3441 GRADE (Login (PK, FK to STUDENT.Login), Grade (PK), LectureCode (FK to LECTURE.Code), LectureYear (FK to LECTURE.Year))
3442 ](fig/rel_mod/PROF_DEPARTMENT_EXTENDED)
3434 3443
3444 For the other questions, refer to this code.
3445
3435 3446 ```{.sqlmysql .numberLines include=code/sql/LECTURE.sql} ```{.sqlmysql .numberLines include=code/sql/LECTURE.sql}
3436 3447 ``` ```
3437
3438 ---
3439
3440 3448
3441 3449 --- ---
3442 3450
 
... ... From relational models to E.R. models (sometimes needed)
3864 3872
3865 3873 ![](img/Reverse_Eng1.jpeg) ![](img/Reverse_Eng1.jpeg)
3866 3874
3867 ![](fig/rel_mod/PROF_DEPARTMENT_EXTENDED)
3868
3869 3875 ![](img/Reverse_Eng3.jpeg) ![](img/Reverse_Eng3.jpeg)
3870 3876
3877
3871 3878 --- ---
3872 3879
3873 3880 ## E.R.-to-Relational Models Mapping ## E.R.-to-Relational Models Mapping
 
... ... Exercise +.#
4360 4367
4361 4368 Exercise +.# Exercise +.#
4362 4369
4363 : What is a partial key?
4364
4365 Exercise +.#
4366
4367 4370 : 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.
4368 4371
4369 4372 <!-- Bug with table --> <!-- Bug with table -->
 
... ... Exercise +.#
4400 4403
4401 4404 Exercise +.# Exercise +.#
4402 4405
4406 : What is a partial key?
4407
4408 Exercise +.#
4409
4403 4410 : Why do weak entity type have a total participation constraint? : Why do weak entity type have a total participation constraint?
4404 4411
4405 4412 Exercise +.# Exercise +.#
 
... ... Solution +.#
4590 4597 Solution +.# Solution +.#
4591 4598
4592 4599 : A relationship type where the same entity type participates more than once. : A relationship type where the same entity type participates more than once.
4593 On rooms, "is to the left of", on persons, "is married to".
4600 On seats, "is to the left of", on persons, "is married to".
4594 4601
4595 4602 Solution +.# Solution +.#
4596 4603
 
... ... Solution +.#
4604 4611
4605 4612 : When the cardinality is $1:N$, $1:1$ or $N:1$. : When the cardinality is $1:N$, $1:1$ or $N:1$.
4606 4613
4607 Solution +.#
4608
4609 : For a weak entity attribute, it is the attribute that can uniquely identify weak entites that are related to the same owner entity.
4610
4611 4614 Solution +.# Solution +.#
4612 4615 ~ ~
4613 4616
 
... ... INSTRUCTOR | $1:N$ | LECTURE | "An instructor can teach multiple lecture, but a
4619 4622 INSTRUCTOR | $1:N$ | OFFICE | "An instructor can have multiple office, but an office belongs to only one instructor" INSTRUCTOR | $1:N$ | OFFICE | "An instructor can have multiple office, but an office belongs to only one instructor"
4620 4623 COMPUTER | $M:N$ | OS| "A computer can have multiple operating system, the same operating system can be installed on more than one computer." COMPUTER | $M:N$ | OS| "A computer can have multiple operating system, the same operating system can be installed on more than one computer."
4621 4624
4622 Some of those choices, of course, are is arguable (typically, almost any combination seems reasonnable for the INSTRUCTOR : OFFICE relation).
4625 Some of those choices, of course, are arguable (typically, almost any combination seems reasonnable for the INSTRUCTOR : OFFICE relation).
4623 4626
4624 4627 Solution +.# Solution +.#
4625 4628
 
... ... Solution +.#
4640 4643
4641 4644 Solution +.# Solution +.#
4642 4645
4643 : Same as before?
4646 : To be written.
4647
4648 Solution +.#
4649
4650 : For a weak entity attribute, it is the attribute that can uniquely identify weak entites that are related to the same owner entity.
4644 4651
4645 4652 Solution +.# Solution +.#
4646 4653
 
... ... The idea was to have
4786 4793
4787 4794 - The `EXAM` table storing information about exams, - The `EXAM` table storing information about exams,
4788 4795 - One entry per problem in the PROBLEM table, and to associate every problem to an exam, - One entry per problem in the PROBLEM table, and to associate every problem to an exam,
4789 - The grade of one student for one particular exam stored in the `STUDENT\_GRADE` table.
4796 - The grade of one student for one particular exam stored in the `STUDENT_GRADE` table.
4790 4797
4791 4798 Unfortunately, this design turned out to be terrible. Unfortunately, this design turned out to be terrible.
4792 4799 Describe at least one common and interesting situation where this model would fail to fulfill its purpose, and propose a way to correct the particular problem you identified. Describe at least one common and interesting situation where this model would fail to fulfill its purpose, and propose a way to correct the particular problem you identified.
 
... ... Problem (Reading the MOVIES database ER schema) +.#movie
4801 4808 ![](img/te) ![](img/te)
4802 4809
4803 4810 Assume that MOVIES is a populated database. Assume that MOVIES is a populated database.
4804 ACTOR is used as a gender-netral term.
4811 ACTOR is used as a gender-neutral term.
4805 4812 Given the constraints shown in the ER schema, respond to the following statements with *True* or *False*. Given the constraints shown in the ER schema, respond to the following statements with *True* or *False*.
4806 4813 Justify each answer. Justify each answer.
4807 4814
 
... ... Problem (Reading the MOVIES database ER schema) +.#movie
4810 4817 #. Some actors could have done a lead role in multiple movies. #. Some actors could have done a lead role in multiple movies.
4811 4818 #. A movie can have only a maximum of two lead actors. #. A movie can have only a maximum of two lead actors.
4812 4819 #. Every director have to have been an actor in some movie. #. Every director have to have been an actor in some movie.
4813 #. No producer has ever been an actor.
4820 #. No producer has ever been an actor.
4814 4821 #. A producer cannot be an actor in some other movie. #. A producer cannot be an actor in some other movie.
4815 4822 #. There could be movies with more than a dozen actors. #. There could be movies with more than a dozen actors.
4816 4823 #. Producers can be directors as well. #. Producers can be directors as well.
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