List of commits:
Subject Hash Author Date (UTC)
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
Working on Ch. 4, adding the content of the weekly announcements to the core of the document, added illustrations on the conversion E.R. -> Rel. model, fixed various typos. 1995837f41c1508ae809d5a91065bdefd5bd6c03 aubert@math.cnrs.fr 2019-03-22 17:27:51
Fixing exercise and normalization in Chapter 4. 7aa4b9a581daf7144dd485ba791b7707585088b8 aubert@math.cnrs.fr 2019-03-20 18:55:42
Quick fix on UML diagrams. 86a52b2f6ce92750bdb2c33eaa4dbc4497322e1c aubert@math.cnrs.fr 2019-03-18 18:37:24
Adding some missing files. 0c090f6d43e84b71ca5e1f6d3e8d1aa0d733824d aubert@math.cnrs.fr 2019-03-18 18:28:32
Fixing the style for line numbers, adding information for weak entities, drawing some figures (for crow's notation, for alternative notations), removing various images. 26ce9a96701649988cfdfcb3e61011f4e154896d aubert@math.cnrs.fr 2019-03-18 18:25:09
Added solution to quiz #4. db0de8ba5c6605d77fdbc076f3a9e5b3851d83e0 aubert@math.cnrs.fr 2019-03-15 20:57:13
Added questions for Quiz #4. 30d908601e9431ec0901d4001ddbf99bf14f75d0 aubert@math.cnrs.fr 2019-03-15 17:52:24
Worked on narrative in Chapter 4, mostly ER diagrams. 9e0cc5fc5a2b4087fe1191f1ba5926f87ad5a7bd aubert@math.cnrs.fr 2019-03-12 18:57:16
Updated list of known bugs. d51ff0a5bb73f09eb8d3eb7520ebb77555911e69 aubert@math.cnrs.fr 2019-03-12 17:09:22
Updating the README with the list of new files. bb35e21746d958d649b226a5857150d975d85403 aubert@math.cnrs.fr 2019-03-07 15:20:04
Commit 4e0ee25d509412e5e455d9ad4c98f7aad8c5a354 - Added a solution to one of the problem of Exam #2, and added the last quiz.
Author: aubert@math.cnrs.fr
Author date (UTC): 2019-04-19 15:14
Committer name: aubert@math.cnrs.fr
Committer date (UTC): 2019-04-19 15:14
Parent(s): 48611244d21515269bae041dc2535b7e08fb5877
Signing key:
Tree: 01708bcad7c904b3ccfb79b39e17e582b749866b
File Lines added Lines deleted
notes/fig/rel_mod/RECORD.tex 89 0
notes/lectures_notes.md 77 3
File notes/fig/rel_mod/RECORD.tex added (mode: 100644) (index 0000000..7a61541)
1 \documentclass[border=20pt]{standalone}
2 \input{template.def}
3
4 % RELEASED(Label (PK, FK to LABEL.Name), Recording (PK, FK to RECORDING.Title), Date)
5 % EXCLUSITIVY(Recording (PK, FK to RECORDING.Title), Shop (FK to SHOP.Name))
6 % RECORDING(Name (PK))
7 % SHOP(Name (PK), StreetName, Citiy, Zip)
8 % LABEL(Name (PK), Phone, LogoName, LogoColor)
9 % SELL(Recording (FK, PK to RECORDING.Title), Shop (PK, FK to SHOP.Name), NumberOfCopies)
10 % LABELGENRE(Label (PK, FK to LABEL.Name), Genre (PK))
11
12 \Frame(0,0){1}[RELEASE]{
13 Label/PK,
14 Recording/PK,
15 Date/A};
16
17 \Frame(0,-2.5){2}[EXCLUSITIVY]{
18 Recording/PK,
19 Shop/A};
20
21 \Frame(6,0){3}[RECORDING]{
22 Title/PK};
23
24 \Frame(6,-2.5){4}[SHOP]{
25 Name/PK,
26 StreetName/A,
27 City/A,
28 Zip/A};
29
30 \Frame(6,-5){5}[LABEL]{
31 Name/PK,
32 Phone/A,
33 LogoName/A,
34 LogoColor/A};
35
36 \Frame(12,0){6}[SELL]{
37 Recording/PK,
38 Shop/PK,
39 NumberOfCopies/A};
40
41
42 \Frame(12,-5){7}[LABELGENRE]{
43 Label/PK,
44 Genre/PK};
45
46 \draw[FK] % From Label1 to Name3⁵
47 (Name5)++(0.1,0) -- ++(0,-.55) -- ++(-7,0)
48 -- ++(0,5) coordinate (inter)
49 -- ++(0.87,0) coordinate (inter)
50 -- (Label1);
51
52 \draw[FK] % From Recording1 to Title3
53 (Title3)++(-0.3,0) -- ++(0,-.55) coordinate (inter)
54 -- (Recording1|- inter) --++(0,0.55);
55
56 \draw[FK] % From Recording2 to Title3
57 (Title3)++(0,0) -- ++(0,-.75) -- ++(-3,0) - ++(0,-2.3)coordinate (inter)
58 -- (Recording2|- inter) --++(0,0.55);
59
60 \draw[FK] % From Shop2 to Name4
61 (Name4)++(-0.1,0) -- ++(0,-.75) -- ++(-3,0) coordinate (inter)
62 -- (Shop2|- inter) --++(0,0.85);
63
64 \draw[FK] % From Recording6 to Title3
65 (Title3)++(0.3,0) -- ++(0,-.55) coordinate (inter)
66 -- (Recording6|- inter) --++(0,0.55);
67
68 \draw[FK] % From Shop6 to Name4
69 (Name4)++(0.3,0) -- ++(0,-.55) coordinate (inter)
70 -- (Shop6|- inter) --++(0,3.05);
71
72 \draw[FK] % From Label7 to Name53
73 (Name5)++(0.3,0) -- ++(0,-.55) coordinate (inter)
74 -- (Label7|- inter) --++(0,0.55);
75
76
77 %
78 %\draw[FK] % From Quest5 to Name4
79 %(Name4)++(-0.1,0) -- ++(0,-.7) -- ++(2.6,0) coordinate (inter)
80 %-- (Quest5 -| inter) -- ++(0,-0.4) coordinate (inter)
81 %-- (Quest5 |- inter) --++(0,0.4);
82 %
83 %\draw[FK] % From Quest6 to Name4
84 %(Name4)++(0.1,0) -- ++(0,-.55) -- ++(2.6,0) coordinate (inter)
85 %-- (Quest6 -| inter) -- ++(0,-0.2) coordinate (inter)
86 %-- (Quest6 |- inter) --++(0,0.3);
87
88 \end{tikzpicture}
89 \end{document}
File notes/lectures_notes.md changed (mode: 100644) (index 45aaa70..b89b2eb)
... ... We could also have used a combination of both!
5657 5657
5658 5658 --- ---
5659 5659
5660 Solution to [%D %n (%T)](#problem:ERtoRELRecord)
5661 ~
5662 "Is it true that …"
5663
5664 <!-- bug with table -->
5665   | Yes | No |
5666 ------------ | --- | --- |
5667 a label can have multiple logos? |   | ✔ |
5668 a recording can be released by multiple labels, at different dates? | ✔ |   |
5669 a record shop can have multiple exclusivities? | ✔ |   |
5670 two record shops can have the same address? | ✔ |   |
5671 two logos can have the same name? | ✔ |   |
5672 two recordings can have the same title? |   | ✔ |
5673 a record shop must sell at least one recording? | ✔ |   |
5674
5675 For the $1:M$ relationship `IS_AN_EXCLUSIVITY_OF`, we can chose between the foreign key and the cross-reference approaches.
5676 For the $1:1$ relationship `USES`, we can use any approach we want (foreign key, merged relation or cross-reference).
5677 We chose to merge the two relations `LABEL` and `LOGO`, and to have a look-up table for the `IS_AN_EXCLUSIVITY_OF` relation, and we obtain:
5678
5679 ![
5680 RELEASED(Label (PK, FK to LABEL.Name), Recording (PK, FK to RECORDING.Title), Date)
5681 EXCLUSITIVY(Recording (PK, FK to RECORDING.Title), Shop (FK to SHOP.Name))
5682 RECORDING(Name (PK))
5683 SHOP(Name (PK), StreetName, Citiy, Zip)
5684 LABEL(Name (PK), Phone, LogoName, LogoColor)
5685 SELL(Recording (FK, PK to RECORDING.Title), Shop (PK, FK to SHOP.Name), NumberOfCopies)
5686 LABELGENRE(Label (PK, FK to LABEL.Name), Genre (PK))
5687 ](fig/rel_mod/RECORD)\
5688
5689 ---
5690
5660 5691 Solution to [%D %n (%T)](#problem:carsale) Solution to [%D %n (%T)](#problem:carsale)
5661 5692 ~ ~
5662 5693
 
... ... Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/HW_DB
6046 6077
6047 6078 ### Creating a table ### Creating a table
6048 6079
6049 Use `stmt.execute` and a create statement.
6050 You can use the `getMetaData()` of the `DatabaseMetaData` to obtain information about the tables.
6080 We can create a table with the method `stmt.execute`.
6081 We can use the `getMetaData()` of the `DatabaseMetaData` to obtain information about the tables.
6051 6082
6052 6083 ### Inserting values ### Inserting values
6053 6084
6054 Use `stmt.executeUpdate` (multiple insertion possible if `allowMultiQueries` was set to true).
6085 Use `stmt.executeUpdate` (multiple insertion possible if `allowMultiQueries` was set to true, cf. <https://stackoverflow.com/a/10804730/>).
6055 6086 Another way of batch processing statements: Another way of batch processing statements:
6056 6087
6057 6088 ~~~{.java} ~~~{.java}
 
... ... Exercise +.#
6083 6114
6084 6115 Exercise +.# Exercise +.#
6085 6116
6117 : Name three classes in the sql API of java.
6118
6119 Exercise +.#
6120
6086 6121 : What JDBC method do you call to get a connection to a database? : What JDBC method do you call to get a connection to a database?
6087 6122
6088 6123 Exercise +.# Exercise +.#
 
... ... Exercise +.#
6114 6149
6115 6150 : In what class is the `getColumnName` method? : In what class is the `getColumnName` method?
6116 6151
6152
6153 Exercise +.#
6154 ~
6155
6156 Assuming `stmt`{.java} is a `Statement`{.java} object, in the statement
6157
6158 ~~~{.java}
6159 modif = stmt.executeUpdate(strC);
6160 ~~~
6161 what is
6162
6163 #. the datatype of `modif`{.java}?
6164 #. the datatype of `strC`{.java}?
6165 #. a(n example of a) possible value for `strC`{.java}?
6166
6167
6117 6168 Exercise +.# Exercise +.#
6118 6169
6119 6170 : What is a prepared statement? : What is a prepared statement?
6120 6171
6172
6173 Exercise +.#
6174
6175 : Assuming `ps` is the prepared statement `INSERT INTO EXAM VALUES (?, ?)`{.sqlmysql}, write the three statements needed to allocate "Quiz" and "5" to the two slots, and then to execute the prepared statement on the database.
6176
6121 6177 Exercise +.#ErrorsInCode Exercise +.#ErrorsInCode
6122 6178 ~ ~
6123 6179
 
... ... Solution +.#
6140 6196
6141 6197 Solution +.# Solution +.#
6142 6198
6199 : You can find them listed at <https://docs.oracle.com/javase/7/docs/api/java/sql/package-summary.html>. We used `Connection`, `DatabaseMetaData`, `ResultSetMetaData`, `PreparedStatement`, `Statement`, ...
6200
6201 Solution +.#
6202
6143 6203 : DriverManager.getConnection() : DriverManager.getConnection()
6144 6204
6145 6205 Solution +.# Solution +.#
 
... ... Solution +.#
6163 6223
6164 6224 : Connect to `localhost:3306` and create a new database if needed, and use secure connection. : Connect to `localhost:3306` and create a new database if needed, and use secure connection.
6165 6225
6226
6227 Solution +.#
6228
6229 : In `modif = stmt.executeUpdate(strC);`{.java}, `modif` is an integer (the number of rows modified by the query), `strC` is a `String` (a SQL command), and an example of value is `DELETE FROM BOOKS Where Price > 0.5`{.sqlmysql}.
6230
6166 6231 Solution +.# Solution +.#
6167 6232
6168 6233 : `ResultSetMetaData` : `ResultSetMetaData`
 
... ... Solution +.#
6171 6236
6172 6237 : A prepared statement is a feature used to execute the same (or similar) SQL statements repeatedly with high efficiency. : A prepared statement is a feature used to execute the same (or similar) SQL statements repeatedly with high efficiency.
6173 6238
6239 Solution +.#
6240 ~
6241
6242 ~~~{.java}
6243 ps.setString(1, "Quiz");
6244 ps.setInt(2, 5);
6245 ps.execute();
6246 ~~~
6247
6174 6248 Solution +.# Solution +.#
6175 6249 ~ ~
6176 6250
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