List of commits:
Subject Hash Author Date (UTC)
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
Started to work on Functional Dep. 2123fbafc3b8258184ad745d8f23521a3f477d0e au 2018-12-22 18:53:20
Commit 0d5a839282b1ae6e6c07e7b12a74ff2f0f2f3b86 - Added the rest of the first exam for Fall 2019.
Author: aubert@math.cnrs.fr
Author date (UTC): 2019-02-22 20:03
Committer name: aubert@math.cnrs.fr
Committer date (UTC): 2019-02-22 20:03
Parent(s): d5bfcbb949a6acac68156a8b37d6f8d23375b1cb
Signer:
Signing key:
Signing status: N
Tree: 4b1ef56af227d4c348db2265ba2244d2cba0a766
File Lines added Lines deleted
notes/fig/rel_mod/BILL.tex 48 0
notes/lectures_notes.md 170 80
File notes/fig/rel_mod/BILL.tex added (mode: 100644) (index 0000000..e50a937)
1 \documentclass[border=20pt]{standalone}
2 \input{template.def}
3
4
5 % BILL(Name, Sponsor (FK to MEMBER.Id), Date, Id (PK))
6 % MEMBER(Name, Political Group, BTerm, ETerm, Id (PK))
7 % REPRESENTATIVE(Role (PK), Member (FK to MEMBER.Id))
8 % VOTE(Bill (PK, FK to BILL.Id), Member (PK, FK to MEMBER.Id))
9
10 \Frame(0,0){1}[BILL]{
11 Name/A,
12 Sponsor/A,
13 Date/A,
14 Id/PK};
15
16 \Frame(0,-2.5){2}[MEMBER]{
17 Name/A,
18 Political Group/A,
19 BTerm/A,
20 ETerm/A,
21 Id/PK};
22
23 \Frame(0,-5){3}[REPRESENTATIVES]{
24 Role/PK,
25 Member/A};
26
27 \Frame(8,0){4}[VOTE]{
28 Bill/PK,
29 Member/PK};
30
31 \draw[FK] % From VOTE.Bill to BILL.Id
32 (Id1) -- ++(0,-.55) coordinate (inter)
33 -- (Bill4 |- inter) --++(0, 0.5);
34
35 \draw[FK] % From VOTE.Member to MEMBER.Id
36 (Id2)++(0.2,0) -- ++(0,-0.6)
37 coordinate (inter) -- (Member4 |- inter) --(Member4);
38
39 \draw[FK] % From BILL.Sponsor to MEMBER.Id
40 (Id2)++(-0.1,0) --++ (0, -0.6) -- ++(-7,0) -- ++(0, 2.5)
41 coordinate (inter) -- (Sponsor1 |- inter) --(Sponsor1);
42
43 \draw[FK] % From REPRESENTATIVES.Role to MEMBER.Id
44 (Id2)++(0.05,0) --++ (0, -3)
45 coordinate (inter) -- (Role3 |- inter) --(Role3);
46
47 \end{tikzpicture}
48 \end{document}
File notes/lectures_notes.md changed (mode: 100644) (index c352277..4bc8dc8)
... ... A typical (metting twice a week, ±17 weeks, ±30 classes) semester is divided a
76 76 - Lecture 29: Introduction to NoSQL - Lecture 29: Introduction to NoSQL
77 77 - Lecture 30: Introduction to MongoDB - Lecture 30: Introduction to MongoDB
78 78
79 For information purposes, a straight line like this:
79 For information purposes, an indication like this:
80 80
81 81 --- ---
82 82
 
... ... To give you a sense of what you will be asked to do during the exams, please fin
102 102 - [%D %n (%T)](#problem:NormalizeContact) - [%D %n (%T)](#problem:NormalizeContact)
103 103 - A variation on [%D %n (%T)](#problem:ERtoRELCountry) - A variation on [%D %n (%T)](#problem:ERtoRELCountry)
104 104 - Final: - Final:
105 - A variation on [%D %n (%T)](#exercise:ErrorsInCode)
105 - A variation on (@exercise:ErrorsInCode)
106 106 - A variation on [%D %n (%T)](#problem:coffee) - A variation on [%D %n (%T)](#problem:coffee)
107 107 - A variation on [%D %n (%T)](#problem:UMLtoRELDriver): students were asked to draw the ER diagram for that schema. - A variation on [%D %n (%T)](#problem:UMLtoRELDriver): students were asked to draw the ER diagram for that schema.
108 108 - [%D %n (%T)](#problem:book) - [%D %n (%T)](#problem:book)
 
... ... To give you a sense of what you will be asked to do during the exams, please fin
111 111 ### Spring 2018 {-} ### Spring 2018 {-}
112 112
113 113 - Exam #1: - Exam #1:
114 - [%D %n (%T)](#problem:cinema), except that I gave some of the relatins and attributes, to help getting started with the problem.
114 - [%D %n (%T)](#problem:cinema), except that I gave some of the relations and attributes, to help getting started with the problem.
115 115 - [%D %n (%T)](#problem:designforprof) - [%D %n (%T)](#problem:designforprof)
116 116 - [%D %n (%T)](#problem:train) - [%D %n (%T)](#problem:train)
117 117 - [%D %n (%T)](#problem:coffee) - [%D %n (%T)](#problem:coffee)
 
... ... To give you a sense of what you will be asked to do during the exams, please fin
128 128 - A variation on [%D %n (%T)](#problem:BusinessToEr) - A variation on [%D %n (%T)](#problem:BusinessToEr)
129 129 - A variation on [%D %n (%T)](#problem:UMLtoRELDriver): students were asked to draw the ER diagram for that schema. - A variation on [%D %n (%T)](#problem:UMLtoRELDriver): students were asked to draw the ER diagram for that schema.
130 130
131 ### Fall 2019 {-}
132
133 - Exam #1:
134 - [%D %n (%T)](#problem:sqlBooks)
135 - Five exercises (@exercise:nameDBMS, @exercise:diff_op_trans, @exercise:dealing_with_violations, @exercise:twice_row_sql)
136 - A variation on [%D %n (%T)](#problem:rel_model_bills)
137
131 138
132 139 ## Typesetting and Acknowledgments {-} ## Typesetting and Acknowledgments {-}
133 140
 
... ... Exercise +.#
327 334
328 335 : What is a virtual data? How can I access it? : What is a virtual data? How can I access it?
329 336
337 Exercise +.#nameDBMS
338
339 : Name two DBMS.
340
330 341 Exercise +.# Exercise +.#
331 342
332 343 : Why do DBMS include concurrency control? : Why do DBMS include concurrency control?
 
... ... Solution +.#
376 387
377 388 Solution +.# Solution +.#
378 389
390 : 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!
391
392 Solution +.#
393
379 394 : To ensure that several users trying to update the same data will do so in a controlled manner. To avoid inconsistency. : To ensure that several users trying to update the same data will do so in a controlled manner. To avoid inconsistency.
380 395
381 396 Solution +.# Solution +.#
 
... ... Tuples can't be equal, so a subset of values must distinguish them, we study the
594 609 - A **candidate key** is a key, a **primary key** is the selected candidate key (it is u͟n͟d͟e͟r͟l͟i͟n͟e͟d͟^[For technical reasons, underlined words cannot be searched in the document.]). - A **candidate key** is a key, a **primary key** is the selected candidate key (it is u͟n͟d͟e͟r͟l͟i͟n͟e͟d͟^[For technical reasons, underlined words cannot be searched in the document.]).
595 610
596 611 Note: here we "retro-fit" those definitions, in DB design, they come first! Note: here we "retro-fit" those definitions, in DB design, they come first!
612 We are making the assumption that the data pre-exist to the specification to make the concept clearer.
597 613
598 614 | A | B | C | D | | A | B | C | D |
599 615 | :---: | :---: | :---: | :---: | | :---: | :---: | :---: | :---: |
 
... ... Note: here we "retro-fit" those definitions, in DB design, they come first!
608 624
609 625 ### Foreign Keys ### Foreign Keys
610 626
611 A **foreign key** is a set of attributes FK in the relation schema R$_1$ is a foreign key of R$_1$ ("referencing relation") that references R$_2$ ("referenced relation") if
627 A **foreign key** (FK) is a set of attributes denoted FK in the relation schema R$_1$, such that FK is a foreign key of R$_1$ ("referencing relation") that references R$_2$ ("referenced relation") if
612 628
613 629 - FK refers to R$_2$ (i.e., the attributes in FK have the same domain(s) as the primary key PK of R$_2$) - FK refers to R$_2$ (i.e., the attributes in FK have the same domain(s) as the primary key PK of R$_2$)
614 630 - a value of FK in a tuple t$_1$ of r$_1$(R$_1$) either - a value of FK in a tuple t$_1$ of r$_1$(R$_1$) either
 
... ... Exercise +.#
749 765
750 766 : Give three examples of operations. : Give three examples of operations.
751 767
768 Exercise +.#diff_op_trans
769
770 : What is the difference between an operation and a transaction?
771
772 Exercise +.#dealing_with_violations
773
774 : Give three different ways to deal with operations whose execution in isolation would result in the violation of one of the constraint.
775
752 776 Exercise +.# Exercise +.#
753 777 ~ ~
754 778 Consider the following two relations: Consider the following two relations:
 
... ... Solution +.#
867 891 a) COMPUTER has for arity $4$, and OS has for arity $3$. a) COMPUTER has for arity $4$, and OS has for arity $3$.
868 892 b) ("Linda McFather", 32, 2017, "Purism"), and ("Debian", "Stable", "amd64") b) ("Linda McFather", 32, 2017, "Purism"), and ("Debian", "Stable", "amd64")
869 893
894
895 Solution +.#
896
897 : 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.
898
899 Solution +.#
900
901 : 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).
902
870 903 Solution +.# Solution +.#
871 904
872 905 : The requirement that each tuple must have for an attribute $A$ an atomic value from the domain dom($A$), or `NULL`{.sqlmysql}. : The requirement that each tuple must have for an attribute $A$ an atomic value from the domain dom($A$), or `NULL`{.sqlmysql}.
 
... ... Problem (Relational model for a cinema company) +.#cinema
946 979 - Each theater can schedule movies at show-times. Each show-time has a unique id, a start time, and is for a specific movie, at a theater auditorium. - Each theater can schedule movies at show-times. Each show-time has a unique id, a start time, and is for a specific movie, at a theater auditorium.
947 980 - The company sells tickets for scheduled show-times. Each ticket has a unique ticket id, and a price. - The company sells tickets for scheduled show-times. Each ticket has a unique ticket id, and a price.
948 981
982 ---
983
984 Problem (Relational model for bills) +.#rel_model_bills
985 ~
986 Propose a relational model for the following situation:
987
988 - You want to store the bills that are debated and voted on at the U.S. House of Representatives. Each bill has a name, a (unique) sponsor which needs to be a member of the house, a date when it was discussed (which may not have been fixed yet).
989 - You want to record the name, political group, beginning and (expected) end of the term of the members of the house.
990 - You also want to record the name of the Speaker, Majority Leader, Minority Leader, Majority Whip, and Minority Whip, which are all members of the house.
991 - Finally, for each bill, you want to record the vote of every member of the house.
992
949 993 ## Solution to Selected Problems {-} ## Solution to Selected Problems {-}
950 994
951 995 Solution to @problem:cinema Solution to @problem:cinema
952 996
953 ![STAR(Id (PK), Name, BirthDate)
954 MOVIE(Id (PK), Title, Year, Length, Genre)
955 FEATURE-IN(StarId (PK, FK to STAR.Id), MovieId (PK, FK to MOVIE.Id))
956 THEATER(Id (PK), Name, Address)
957 AUDITORIUM(Id (PK), Capacity, Theater (FK to THEATER.Id))
958 SHOWTIME(Id (PK), MovieId (FK to MOVIE.Id), AuditoriumId (FK to AUDITORIUM.Id), StartTime)
959 TICKETS(Id (PK), ShowTimeId (FK to SHOWTIME.Id), Price)
960 ](fig/rel_mod/CINEMA)
961 \
997 ~
998
999 ![STAR(Id (PK), Name, BirthDate)
1000 MOVIE(Id (PK), Title, Year, Length, Genre)
1001 FEATURE-IN(StarId (PK, FK to STAR.Id), MovieId (PK, FK to MOVIE.Id))
1002 THEATER(Id (PK), Name, Address)
1003 AUDITORIUM(Id (PK), Capacity, Theater (FK to THEATER.Id))
1004 SHOWTIME(Id (PK), MovieId (FK to MOVIE.Id), AuditoriumId (FK to AUDITORIUM.Id), StartTime)
1005 TICKETS(Id (PK), ShowTimeId (FK to SHOWTIME.Id), Price)
1006 ](fig/rel_mod/CINEMA)
1007 \
1008
1009 ---
1010
1011 Solution to @problem:rel_model_bills
1012
1013 ~
1014
1015 Be careful: saying that a bill has a unique sponsor does *not* imply that a the sponsor is a good primary key for the bills: a house member could very well be the sponsor of multiple bills! It just implies that a single attribute is enough to hold the name of the sponsor.
1016
1017 ![BILL(Name, Sponsor (FK to MEMBER.Id), Date, Id (PK))
1018 MEMBER(Name, Political Group, BTerm, ETerm, Id (PK))
1019 REPRESENTATIVE(Role (PK), Member (FK to MEMBER.Id))
1020 VOTE(Bill (PK, FK to BILL.Id), Member (PK, FK to MEMBER.Id))
1021 ](fig/rel_mod/BILL)
1022 \
1023
1024 For simplicity, we added an `Id` to our `MEMBER` and `BILL` relations. Note that having a "role" in the `MEMBER` relation to store the information about speaker, etc., would be extremely inefficient, since we would add an attribute to the ~435 members that would be `NULL` in ~430 of them.
962 1025
963 1026 # The SQL Programming Language # The SQL Programming Language
964 1027
 
... ... CREATE TABLE Table_default(
1270 1333 FOREIGN KEY (Attribute2) REFERENCES F_Key(Attribute) FOREIGN KEY (Attribute2) REFERENCES F_Key(Attribute)
1271 1334 ); );
1272 1335
1273
1336 -- By default, this foreign key will restrict.
1337
1274 1338 CREATE TABLE Table_restrict( CREATE TABLE Table_restrict(
1275 1339 Attribute1 VARCHAR(25) PRIMARY KEY, Attribute1 VARCHAR(25) PRIMARY KEY,
1276 1340 Attribute2 VARCHAR(25), Attribute2 VARCHAR(25),
 
... ... SELECT Name FROM PROF
1549 1613
1550 1614 --- ---
1551 1615
1616
1617 ## Three-Valued Logic
1618
1619 Cf. [@Textbook6, 5.1.1], [@Textbook7, 7.1.1]
1620
1621 ### Meaning of `NULL`
1622
1623 `NULL` is
1624
1625 #. Unknown value ("Nobody knows")
1626
1627 > What is the date of birth of [Jack the Ripper](https://en.wikipedia.org/wiki/Jack_the_Ripper)?
1628
1629 > [Does P equal NP?](https://en.wikipedia.org/wiki/List_of_unsolved_problems_in_computer_science)
1630
1631 #. Unavailable / Withheld ("I don't have that information with me at the moment")
1632
1633 > What is the number of english spies in France?
1634
1635 > What is the VIN of your car?
1636
1637 > What is the identity of the Tiananmen Square person?
1638
1639 #. Not Applicable ("Your question doesn't make sense")
1640
1641 > What is the US SSN of a french person?
1642
1643 > What is the email address of an author of the XIXth century?
1644
1645 ### Comparison with unknown values {truth_tables}
1646
1647 If `NULL` is involved in a comparison, the result evaluates to "**U**nknown".
1648
1649 ||||
1650 :--: | :--: | :--: | :--:
1651 **AND** | T | F | U
1652 T | T | F | U
1653 F | F | F | F
1654 U | U | F | U
1655
1656 ||||
1657 :--: | :--: | :--: | :--:
1658 **OR** | T | F | U
1659 T | T | T | T
1660 F | T | F | U
1661 U | T | U | U
1662
1663
1664 ||
1665 :--: | :--:
1666 **NOT** | \
1667 T | F
1668 F | T
1669 U | U
1670
1671 You can test if a value is `NULL` with `IS NULL`.
1672
1673 ~~~{.sqlmysql .numberLines}
1674 INSERT INTO DEPARTMENT Values ('Hist', 'History', NULL);
1675 SELECT * FROM DEPARTMENT WHERE Head IS NULL;
1676 SELECT * FROM DEPARTMENT WHERE Head IS NOT NULL;
1677 SELECT COUNT(*) FROM GRADE WHERE Grade IS NULL;
1678 ~~~
1679
1552 1680 ## Various Tools ## Various Tools
1553 1681
1554 1682 For `DISTINCT`, `ALL` and `UNION`, cf. [@Textbook6, 4.3.4] or [@Textbook7, 6.3.4]. For `DISTINCT`, `ALL` and `UNION`, cf. [@Textbook6, 4.3.4] or [@Textbook7, 6.3.4].
 
... ... SELECT Login AS Username FROM PROF;
1654 1782
1655 1783 The purpose of aliases will be clearer as we study select-project-join queries. The purpose of aliases will be clearer as we study select-project-join queries.
1656 1784
1657 ## Three-Valued Logic
1658
1659 Cf. [@Textbook6, 5.1.1], [@Textbook7, 7.1.1]
1660
1661 ### Meaning of `NULL`
1662
1663 `NULL` is
1664
1665 #. Unknown value ("Nobody knows")
1666
1667 > What is the date of birth of [Jack the Ripper](https://en.wikipedia.org/wiki/Jack_the_Ripper)?
1668
1669 > [Does P equal NP?](https://en.wikipedia.org/wiki/List_of_unsolved_problems_in_computer_science)
1670
1671 #. Unavailable / Withheld ("I don't have that information with me at the moment")
1672
1673 > What is the number of english spies in France?
1674
1675 > What is the VIN of your car?
1676
1677 > What is the identity of the Tiananmen Square person?
1678
1679 #. Not Applicable ("Your question doesn't make sense")
1680
1681 > What is the US SSN of a french person?
1682
1683 > What is the email address of an author of the XIXth century?
1684
1685 ### Comparison with unknown values
1686
1687 If `NULL` is involved in a comparison, the result evaluates to "**U**nknown".
1688
1689 ||||
1690 :--: | :--: | :--: | :--:
1691 **AND** | T | F | U
1692 T | T | F | U
1693 F | F | F | F
1694 U | U | F | U
1695
1696 ||||
1697 :--: | :--: | :--: | :--:
1698 **OR** | T | F | U
1699 T | T | T | T
1700 F | T | F | U
1701 U | T | U | U
1702
1703
1704 ||
1705 :--: | :--:
1706 **NOT** | \
1707 T | F
1708 F | T
1709 U | U
1710
1711 You can test if a value is `NULL` with `IS NULL`.
1712
1713 ~~~{.sqlmysql .numberLines}
1714 INSERT INTO DEPARTMENT Values ('Hist', 'History', NULL);
1715 SELECT * FROM DEPARTMENT WHERE Head IS NULL;
1716 SELECT * FROM DEPARTMENT WHERE Head IS NOT NULL;
1717 SELECT COUNT(*) FROM GRADE WHERE Grade IS NULL;
1718 ~~~
1719
1720 1785
1721 1786 ## More Select Queries ## More Select Queries
1722 1787
 
... ... WHERE DEPARTMENT = ( SELECT Major
1836 1901 becomes becomes
1837 1902
1838 1903 ~~~{.sqlmysql .numberLines} ~~~{.sqlmysql .numberLines}
1839 SELECT STUDENT.Login
1904 SELECT PROF.Login
1840 1905 FROM PROF, STUDENT FROM PROF, STUDENT
1841 1906 WHERE DEPARTMENT = Major AND STUDENT.Login = "cjoella"; WHERE DEPARTMENT = Major AND STUDENT.Login = "cjoella";
1842 1907 ~~~ ~~~
 
... ... Exercise +.#
2212 2277
2213 2278 : Write a statement that inserts the values `"Thomas"` and `4` into the table `TRAINS`. : Write a statement that inserts the values `"Thomas"` and `4` into the table `TRAINS`.
2214 2279
2215 Exercise +.#
2280 Exercise +.#explainfk
2216 2281 ~ ~
2217 2282
2218 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?
 
... ... Exercise +.#
2340 2405 - `NOT UNKNOWN` - `NOT UNKNOWN`
2341 2406 - `FALSE OR UNKNOWN` - `FALSE OR UNKNOWN`
2342 2407
2408 Exercise +.#truthTableAnd
2409
2410 : Write the truth table for `AND`{.sqlmysql} for the three-valued logic of `SQL`.
2411
2343 2412 Exercise +.# Exercise +.#
2344 2413
2345 2414 : What comparison expression should you use to test if a value is different from `NULL`? : What comparison expression should you use to test if a value is different from `NULL`?
 
... ... Exercise +.#
2382 2451
2383 2452 : Write a query that removes the default value for a `Pages` attribute in a `BOOK` table. : Write a query that removes the default value for a `Pages` attribute in a `BOOK` table.
2384 2453
2454 Exercise +.#twice_row_sql
2455
2456 : Under which conditions does `SQL` allow you to enter the same row in a table twice?
2457
2385 2458 #### Exercises {-} #### Exercises {-}
2386 2459
2387 2460 ## Solution to Exercises {-} ## Solution to Exercises {-}
2388 2461
2389 2462 Solution +.# Solution +.#
2390 2463
2391 : It can specify the conceptual and internal schema, **and** it can manipulate the data.
2464 : It can specify the conceptual and internal schema, **and** it can manipulate the data.
2392 2465
2393 2466 Solution +.# Solution +.#
2394 2467
 
... ... Solution +.#
2531 2604 - `FALSE OR UNKNOWN`{.sqlmysql} → `FALSE`{.sqlmysql} - `FALSE OR UNKNOWN`{.sqlmysql} → `FALSE`{.sqlmysql}
2532 2605
2533 2606
2607 Solution +.#
2608 ~
2609
2610 - `TRUE AND TRUE`{.sqlmysql} → `TRUE`{.sqlmysql}
2611 - `TRUE AND FALSE`{.sqlmysql} → `FALSE`{.sqlmysql}
2612 - `TRUE AND UNKNOWN`{.sqlmysql} → `UNKNOWN`{.sqlmysql}
2613 - `FALSE AND FALSE`{.sqlmysql} → `FALSE`{.sqlmysql}
2614 - `UNKNOWN AND UNKNOWN`{.sqlmysql} → `UNKNOWN`{.sqlmysql}
2615 - `FALSE AND UNKNOWN`{.sqlmysql} → `FALSE`{.sqlmysql}
2616 - The other cases can be deduced by symmetry.
2617
2618 For a more compact presentation, refer to (#truth_tables).
2619
2534 2620 Solution +.# Solution +.#
2535 2621
2536 2622 : `IS NOT`{.sqlmysql} : `IS NOT`{.sqlmysql}
 
... ... Solution +.#
2563 2649
2564 2650 : `ALTER TABLE BOOK ALTER COLUMN Pages DROP DEFAULT;`{.sqlmysql} : `ALTER TABLE BOOK ALTER COLUMN Pages DROP DEFAULT;`{.sqlmysql}
2565 2651
2652 Solution +.#
2653
2654 : Essentially, if there are no primary key in the relation, and if no attribute has the `UNIQUE`{.sqlmysql} constraint. Cf. also [%D %n (%T)](#problem:repetition).
2655
2566 2656
2567 2657 ## Problems {-} ## Problems {-}
2568 2658
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