List of commits:
Subject Hash Author Date (UTC)
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
Adding a list of bug, and the sketch of a guide to contribute. 3a94b1fa49aee97001a45325f3f10f09475bf388 aubert@math.cnrs.fr 2019-03-07 15:14:38
Fixed the size of the images, added mention of the support of Affordable Learning Georgia. 485cf486d8d2b08427e5d02eda56d5b7a9495b38 aubert@math.cnrs.fr 2019-03-05 19:37:39
Commit 0fcb73dcc60aef476899c4efea092c99dd6027db - patching a few glitches with the java code and the mysql code used in the demo for the first program.
Author: aubert@math.cnrs.fr
Author date (UTC): 2019-04-04 21:55
Committer name: aubert@math.cnrs.fr
Committer date (UTC): 2019-04-04 21:55
Parent(s): dd409ab3fd6736af4b8adaac284ee101b9770f60
Signing key:
Tree: 10308b27ef828cd8e99573aad18bf10d0227ff3b
File Lines added Lines deleted
notes/code/sql/HW_EBOOKSHOP.sql 14 11
notes/code/sql/HW_FACULTY.sql 10 0
notes/lectures_notes.md 11 3
File notes/code/sql/HW_EBOOKSHOP.sql changed (mode: 100644) (index 7b07a5b..e39ad21)
1 1 /* code/sql/HW_EBOOKSHOP.sql */ /* code/sql/HW_EBOOKSHOP.sql */
2 2
3 -- DROP DATABASE HW_EBOOKSHOP;
3 4 CREATE DATABASE HW_EBOOKSHOP; CREATE DATABASE HW_EBOOKSHOP;
4 5
5 USE HW_eBOOKShop;
6 USE HW_EBOOKSHOP;
6 7
7 8 CREATE TABLE BOOKS ( CREATE TABLE BOOKS (
8 id int PRIMARY KEY,
9 title varchar(50),
10 author varchar(50),
11 price float,
12 qty int
9 id INT PRIMARY KEY,
10 title VARCHAR(50),
11 author VARCHAR(50),
12 price DECIMAL(10, 2),
13 qty INT
13 14 ); );
14 15
15 INSERT INTO BOOKS VALUES (1001, 'Java for dummies', 'Tan Ah Teck', 11.11, 11);
16 INSERT INTO BOOKS VALUES (1002, 'More Java for dummies', 'Tan Ah Teck', 22.22, 22);
17 INSERT INTO BOOKS VALUES (1003, 'More Java for more dummies', 'Mohammad Ali', 33.33, 33);
18 INSERT INTO BOOKS VALUES (1004, 'A Cup of Java', 'Kumar', 44.44, 44);
19 INSERT INTO BOOKS VALUES (1005, 'A Teaspoon of Java', 'Kevin Jones', 55.55, 55);
16 /* Cf. https://en.wikipedia.org/wiki/List_of_best-selling_books */
17
18 INSERT INTO BOOKS VALUES (1, 'The Communist Manifesto', 'Karl Marx and Friedrich Engels', 11.11, 11);
19 INSERT INTO BOOKS VALUES (2, 'Don Quixote', 'Miguel de Cervantes', 22.22, 22);
20 INSERT INTO BOOKS VALUES (3, 'A Tale of Two Cities', 'Charles Dickens', 33.33, 33);
21 INSERT INTO BOOKS VALUES (4, 'The Lord of the Rings', 'J. R. R. Tolkien', 44.44, 44);
22 INSERT INTO BOOKS VALUES (5, 'Le Petit Prince', 'Antoine de Saint-Exupéry', 55.55, 55);
20 23
21 24 SELECT * FROM BOOKS; SELECT * FROM BOOKS;
File notes/code/sql/HW_FACULTY.sql changed (mode: 100644) (index 8157e45..27dd8ad)
... ... CREATE TABLE HW_FACULTY.PROF(
25 25 PRIMARY KEY(Fname, Hiring) PRIMARY KEY(Fname, Hiring)
26 26 ); );
27 27
28 /*
29 * There are many other datatypes in SQL.
30 * For monetary amount, you can use e.g. DECIMAL(10, 2)
31 * cf. the discussion at
32 * https://stackoverflow.com/q/4397302/
33 * and the documentation at
34 * https://dev.mysql.com/doc/refman/5.7/en/precision-math-decimal-characteristics.html
35 */
36
37
28 38 /* Or, instead of using the fully qualified name HW_FACULTY.PROF, we could have: /* Or, instead of using the fully qualified name HW_FACULTY.PROF, we could have:
29 39 USE HW_FACULTY; USE HW_FACULTY;
30 40 CREATE TABLE PROF(…) CREATE TABLE PROF(…)
File notes/lectures_notes.md changed (mode: 100644) (index 8df2598..c4c3853)
... ... For a quick introduction to Java, cf. <http://spots.augusta.edu/caubert/teaching
5820 5820
5821 5821 ## A First Program ## A First Program
5822 5822
5823 We will write and compile a simple java program that manipulates a simple database.
5823 We will write and compile a simple java program that manipulates a simple database^[This program ows a lot to the one presented at <http://www.ntu.edu.sg/home/ehchua/programming/java/jdbc_basic.html>.]
5824 5824 Even if the creation and population of the database could have been done from within the program, we will do it as a preliminary step, using the C.L.I., to make our program simpler. Even if the creation and population of the database could have been done from within the program, we will do it as a preliminary step, using the C.L.I., to make our program simpler.
5825 5825
5826 5826 ### The database (`sql`) ### The database (`sql`)
 
... ... at FirstProg.main(FirstProg.java:9)
5917 5917
5918 5918 A couple of comments: A couple of comments:
5919 5919
5920 - `java.sql.*` contains the classes `Connection`, `Statement`, `ResultSet`, `ResultSetMetadata`.
5920 - `java.sql.*`, whose documentation is at <https://docs.oracle.com/javase/8/docs/api/java/sql/package-summary.html>, contains the classes
5921 - `DriverManager`, used for managing a set of JDBC drivers,
5922 - `Connection`, used to make a connection with a database via the `DriverManager`,
5923 - `Statement`, used to send basic SQL statements via the `Connection`,
5924 - `ResultSet`, to retriev and update the results of a query, returned by a `Statement` object,
5925 - `ResultSetMetadata`, to get information about the columns of a `ResultSet` object,
5926 - `SQLException`, a class of exceptions relative to `SQL`.
5927
5928 - Intuitively, a `Connection` is a bridge (the physical connection), and `Statement` is a lane (a symbolic, or logic, path on the bridge).
5921 5929 - In the string `"jdbc:mysql://localhost:3306/HW_EBOOKSHOP"`, `jdbc` is the protocol, `mysql` is the subprotocol, `localhost` is the url of the database, `3306` is the port, and `HW_EBOOKSHOP` is the schema (that needs to already exist in this case). - In the string `"jdbc:mysql://localhost:3306/HW_EBOOKSHOP"`, `jdbc` is the protocol, `mysql` is the subprotocol, `localhost` is the url of the database, `3306` is the port, and `HW_EBOOKSHOP` is the schema (that needs to already exist in this case).
5922 5930 - Note that `strSelect` doesn't end with `;` (it could, but doesn't have to). - Note that `strSelect` doesn't end with `;` (it could, but doesn't have to).
5923 - `next()` returns true if there is something left in the set of result, and move to the next line if it is the case. It is close to the code we would use to read from a file.
5931 - `next()` returns true if there is something left in the set of result, and move to the next line if it is the case. It is close to the code we would use to read from a file. If you try to use `getString` _before_ moving to the first row, you'll get an error like `java.sql.SQLException: Before start of result set`.
5924 5932 - We could use `1`, `2`, and `3` instead of `"title"`, `"price"` and `"qty"` in the `while` loop: `getString`, `getDouble` and `getInt` also take integers, corresponding to the position of the attribute in the result set. - We could use `1`, `2`, and `3` instead of `"title"`, `"price"` and `"qty"` in the `while` loop: `getString`, `getDouble` and `getInt` also take integers, corresponding to the position of the attribute in the result set.
5925 5933
5926 5934
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