List of commits:
Subject Hash Author Date (UTC)
Adding the temp file, trying to patch the numbering of exercises inside problems. e4e4624cd1037e65a45e8690f2b92e183714b486 aubert@math.cnrs.fr 2018-05-24 19:22:13
Cleaned up the code, fixed some typos, added a list of problems, started working onthe problem for SQL. 701556c081df0bbf8e8800106c7aa4c997e560de aubert@math.cnrs.fr 2018-05-24 07:21:26
Finishing exo for chapter SQL aea58f58f06d99615ae7cb85247bdc08c5ce9d96 aubert@math.cnrs.fr 2018-05-23 17:52:51
Progress on the SQL chapter. e13cddc35a709c6714a90b21d8ed8db6b037793c aubert@math.cnrs.fr 2018-05-23 05:12:21
Started type some relational model examples in latex, reviewed chapter 1 and 2. 1ddf3000e0cb4f8f02b2b2de1ffd8ae14a81c9dc aubert@math.cnrs.fr 2018-05-22 21:09:12
Finished correcting Chapter 1. Added a preamble and tweaked a lot (math, references, titles of subsubsections, etc.) acdd1bb083cd6985763afd9b77e1b7995dc1ebd7 aubert@math.cnrs.fr 2018-05-22 07:02:51
Cleaning latex dependencies: removed colors, fonts, etc., added header and footer. b4c1232d6091e12bc2cdf038529921143a55b758 aubert@math.cnrs.fr 2018-05-22 05:06:04
Putting all latex material aside, changing class. e43fb54e6ecb0ec4669ed16feba940b47ee3e35c aubert@math.cnrs.fr 2018-05-21 15:14:48
Gathering references, fixing many small typos, adding references in bib. 4f5281a0770f07d2f48f36462ab25f0a3945f4e0 aubert@math.cnrs.fr 2018-05-21 04:54:59
Finished merging exercises into lecture notes! 36e1f79080a8ac56837632bcac2c119fc3efa24f aubert@math.cnrs.fr 2018-05-20 18:50:54
Almost done with the homeworks! f82824a2ca9769a0ecf8fc75d6bf1cae1ef3c7a4 aubert@math.cnrs.fr 2018-05-20 05:23:43
Travail sur intégration des exos dans les notes. c5a6676f85953c7bec9bb2de99bed3552ecf52af aubert@math.cnrs.fr 2018-05-20 05:04:30
Les exercises compilent :-) d4230fce5210d1d8905a42d11634e49e82217541 aubert@math.cnrs.fr 2018-05-19 19:09:56
Progrès sur exercises. 40dd86cdc624209a2282d4437921f46325c2cfa1 aubert@math.cnrs.fr 2018-05-19 18:34:07
Working on exercises. 42549c8d28249f1ecf85dd21f6d004ae63c533ad aubert@math.cnrs.fr 2018-05-19 05:43:04
Working on incorporating the exercises. f32148faeb8b11425fe9a57770db9bc85ae02c34 aubert@math.cnrs.fr 2018-05-19 04:51:37
working on sum for exo. 5fb55d2c31b06161ade3a7cae707485d8c02447a aubert@math.cnrs.fr 2018-05-18 21:12:56
Adding various small notes. 5eac6e0b19441fca9a3f70f239d5cbbc4d769976 aubert@math.cnrs.fr 2018-05-17 20:37:14
First pass over! ea1e4f6ddabd91287d10384dc8f28565a762526b aubert@math.cnrs.fr 2018-05-17 19:26:28
Working on notes on normal forms. 58bfcedc6bd6336592a5f93a43ffc0aaf64fa8f6 aubert@math.cnrs.fr 2018-05-16 16:40:12
Commit e4e4624cd1037e65a45e8690f2b92e183714b486 - Adding the temp file, trying to patch the numbering of exercises inside problems.
Author: aubert@math.cnrs.fr
Author date (UTC): 2018-05-24 19:22
Committer name: aubert@math.cnrs.fr
Committer date (UTC): 2018-05-24 19:22
Parent(s): 701556c081df0bbf8e8800106c7aa4c997e560de
Signer:
Signing key:
Signing status: N
Tree: 15c8423bc60efd4ffd13552230f506f3fdfe711d
File Lines added Lines deleted
notes/00_sum.md 30 26
notes/temp.md 145 0
File notes/00_sum.md changed (mode: 100644) (index b1c63c6..d6dc62b)
... ... On top of the [references](references) and of the "resources" listed at the begi
114 114 - Make better makefile (compile images in latex, clean up, etc.). - Make better makefile (compile images in latex, clean up, etc.).
115 115 - Check that order of exercises / problems match introduction in lecture. - Check that order of exercises / problems match introduction in lecture.
116 116 - Check that solution of exercises numbering match exercise numbering. - Check that solution of exercises numbering match exercise numbering.
117 - numbering of Question in exercises is faulty: 1 numbering for all exercises!
117 118
118 119 # Introduction # Introduction
119 120
 
... ... GRANT ALL PRIVILEGES ON `HW\_%` . * TO
2024 2025 'testuser'@'localhost'; 'testuser'@'localhost';
2025 2026 ~~~ ~~~
2026 2027
2027 Be careful: backticks (`` ` ``) are surrounding `HW\_` whereas single quotes (`'`) are surrounding `testuser` and `localhost`.
2028 Be careful: backticks (`` ` ``) are surrounding `HW\_%` whereas single quotes (`'`) are surrounding `testuser` and `localhost`.
2028 2029
2029 2030 And then we quit the DBMS, using And then we quit the DBMS, using
2030 2031
 
... ... Now, let us create our first schema, our first table, populate it with data, and
2077 2078 We first create the schema (or database), `HW_FirstTest`: We first create the schema (or database), `HW_FirstTest`:
2078 2079
2079 2080 ~~~{.sqlmysql} ~~~{.sqlmysql}
2080 CREATE DATABASE HW_FirstTest;
2081 CREATE DATABASE HW_FirstTest; -- Or CREATE SCHEMA HW_FirstTest;
2081 2082 ~~~ ~~~
2082 2083
2083 2084 Let us make sure that we created it: Let us make sure that we created it:
 
... ... And see what it contains now:
2098 2099 SHOW TABLES; SHOW TABLES;
2099 2100 ~~~ ~~~
2100 2101
2101 We now create a table called `TableTest`:
2102 We now create a table called `TableTest`, wtih two integer attributes called `Attribute1` and `Attribute2`:
2102 2103
2103 2104 ~~~{.sqlmysql} ~~~{.sqlmysql}
2104 2105 CREATE TABLE TableTest (Attribute1 INT, Attribute2 INT); CREATE TABLE TableTest (Attribute1 INT, Attribute2 INT);
2105 2106 ~~~ ~~~
2106 2107
2107 And can make sure that it was indeed created:
2108 And can make sure that the table was indeed created:
2108 2109
2109 2110 ~~~{.sqlmysql} ~~~{.sqlmysql}
2110 2111 SHOW TABLES; SHOW TABLES;
 
... ... Those are the commands implemented in the DBMS you are actually using.
2207 2208 Since there are small variations from one implementation to the other, it's better to take one of this link as a reference in the future. Since there are small variations from one implementation to the other, it's better to take one of this link as a reference in the future.
2208 2209
2209 2210
2210 Problem (SQL -- Creating and using a simple table) +.#address
2211 Problem (Creating and using a simple table in SQL) +.#address
2211 2212
2212 Question -.#
2213 [Pb %s.%c](#problem:address) -- Question -.#
2213 2214 ~ Log in as `testuser`, create a database named `HW_Address`, use it, and create two tables: ~ Log in as `testuser`, create a database named `HW_Address`, use it, and create two tables:
2214 2215
2215 2216 ~~~{.sqlmysql .numberLines} ~~~{.sqlmysql .numberLines}
 
... ... CREATE TABLE ADDRESS(
2228 2229 ); );
2229 2230 ~~~ ~~~
2230 2231
2231 Question -.#
2232 [Pb %s.%c](#problem:address) -- Question -.#
2232 2233 ~ Observe the output produced by the command ~ Observe the output produced by the command
2233 2234
2234 2235 ~~~{.sqlmysql} ~~~{.sqlmysql}
2235 2236 DESC ADDRESS; DESC ADDRESS;
2236 ~~
2237
2237 ~~~
2238 2238
2239 Question -.#
2239 [Pb %s.%c](#problem:address) -- Question -.#
2240 2240 ~ Add a foreign key to the `ADDRESS` table, using ~ Add a foreign key to the `ADDRESS` table, using
2241 2241
2242 2242 ~~~{.sqlmysql} ~~~{.sqlmysql}
 
... ... Question -.#
2251 2251 DESC ADDRESS; DESC ADDRESS;
2252 2252 ~~~ ~~~
2253 2253
2254 Is it what you would have expected? How informative is it? Can you think of a command that would output more detailled information?
2254 Is it what you would have expected? How informative is it? Can you think of a command that would output more detailled information, including a reference to the existence of the foreign key?
2255 2255
2256 Question -.#
2257 ~ Draw the relations corresponding to that database, including the primary, as well as foreign, keys.
2256 [Pb %s.%c](#problem:address) -- Question -.#
2257 ~ Draw the relational model corresponding to that database, including the primary, as well as foreign, keys.
2258 2258
2259 Question -.#
2259 [Pb %s.%c](#problem:address) -- Question -.#
2260 2260 ~ Add some data in the `NAME` table: ~ Add some data in the `NAME` table:
2261 2261
2262 2262 ~~~{.sqlmysql} ~~~{.sqlmysql}
 
... ... Question -.#
2268 2268 What command can you use to display this infomation back? What command can you use to display this infomation back?
2269 2269 Do you notice anything regarding the values we entered for the `Id` attribute? Do you notice anything regarding the values we entered for the `Id` attribute?
2270 2270
2271 Question -.#
2271 [Pb %s.%c](#problem:address) -- Question -.#
2272 2272 ~ Add some data into the `ADDRESS` table: ~ Add some data into the `ADDRESS` table:
2273 2273
2274 2274 ~~~{.sqlmysql} ~~~{.sqlmysql}
 
... ... Question -.#
2281 2281
2282 2282 What difference do you note with the insertions we made in the `NAME` table. Which syntax seem more easy to you? What difference do you note with the insertions we made in the `NAME` table. Which syntax seem more easy to you?
2283 2283
2284 Question -.#
2284 [Pb %s.%c](#problem:address) -- Question -.#
2285 2285 ~ Write a `SELECT` statement that returns the `Id` number of the person whose first name is "Samantha". ~ Write a `SELECT` statement that returns the `Id` number of the person whose first name is "Samantha".
2286 2286
2287 Question -.#
2287 [Pb %s.%c](#problem:address) -- Question -.#
2288 2288 ~ Write a statement that violate the entity integrity constraint. What is the error message returned? ~ Write a statement that violate the entity integrity constraint. What is the error message returned?
2289 2289
2290 Question -.#
2290 [Pb %s.%c](#problem:address) -- Question -.#
2291 2291 ~ Execute an `UPDATE` statement that violate the referential integrity constraint. What is the error message returned? ~ Execute an `UPDATE` statement that violate the referential integrity constraint. What is the error message returned?
2292 2292
2293 Question -.#
2293 [Pb %s.%c](#problem:address) -- Question -.#
2294 2294 ~ Write a statement that violate another kind of constraint. Explain what constraint you are violating, and explain the error message. ~ Write a statement that violate another kind of constraint. Explain what constraint you are violating, and explain the error message.
2295 2295
2296 2296
2297 Problem (Repetiting tuples in MySQL) +.-.#repetition
2297 Problem (Duplicate rows in SQL) +.#repetition
2298 2298
2299 Log in as `testuser` and create a database `HW_2Q4`. Tell MySQL that you want to use that database, and create a table (I will assume you named it `EXAMPLE` in the following, but you are free to name it the way you want) with at least two attributes that have different data types. Don't declare a primary key yet. Answer the following:
2299 Log in as `testuser` and create a database `HW_REPETITION`.
2300 Create in that database a table (I will assume you named it `EXAMPLE` in the following, but you are free to name it the way you want) with at least two attributes that have different data types. Don't declare a primary key yet. Answer the following:
2300 2301
2301 #. Add a tuple to your table using
2302 [Pb %s.%c](#problem:repetition) -- Question -.#
2303 ~ Add a tuple to your table using
2302 2304
2303 2305 ~~~{.sqlmysql} ~~~{.sqlmysql}
2304 2306 INSERT INTO EXAMPLE VALUES(X, Y); INSERT INTO EXAMPLE VALUES(X, Y);
 
... ... Log in as `testuser` and create a database `HW_2Q4`. Tell MySQL that you want to
2313 2315
2314 2316 to observe what is stored in this table.) to observe what is stored in this table.)
2315 2317
2316 #. Alter your table to add a primary key, using
2318 [Pb %s.%c](#problem:repetition) -- Question -.#
2319 ~ Alter your table to add a primary key, using
2317 2320
2318 2321 ~~~{.sqlmysql} ~~~{.sqlmysql}
2319 2322 ALTER TABLE EXAMPLE ADD PRIMARY KEY (Attribute); ALTER TABLE EXAMPLE ADD PRIMARY KEY (Attribute);
 
... ... Log in as `testuser` and create a database `HW_2Q4`. Tell MySQL that you want to
2321 2324
2322 2325 where `Attribute` is the name of the attribute you want to be a primary key. What do you observe? where `Attribute` is the name of the attribute you want to be a primary key. What do you observe?
2323 2326
2324 #. Empty your table using
2327 [Pb %s.%c](#problem:repetition) -- Question -.#
2328 ~ Empty your table using
2325 2329
2326 2330 ~~~{.sqlmysql} ~~~{.sqlmysql}
2327 2331 DELETE FROM EXAMPLE; DELETE FROM EXAMPLE;
 
... ... Log in as `testuser` and create a database `HW_2Q4`. Tell MySQL that you want to
2329 2333
2330 2334 and alter your table to add a primary key, using the command we gave at the previous step. What do you observe? and alter your table to add a primary key, using the command we gave at the previous step. What do you observe?
2331 2335
2332 #. Try to add the same tuple twice. What do you observe?
2333
2336 [Pb %s.%c](#problem:repetition) -- Question -.#
2337 ~ Try to add the same tuple twice. What do you observe?
2334 2338
2335 2339
2336 2340 ### Prof Revisited ### Prof Revisited
File notes/temp.md added (mode: 100644) (index 0000000..cee6465)
1 ---
2 documentclass: scrreprt
3 papersize: letter
4 bibliography: [ bib/bib.bib ]
5 link-citations: true
6 title: CSCI 3410 - Database Systems
7 subtitle: Lecture Notes (Draft)
8 author: Clément Aubert
9 institute: Augusta University
10 dir: ltr
11 lang: en
12 numbersections: true
13 mainfont: Linux Libertine O
14 copyright: TEST
15 keywords:
16 - Computer Science
17 - Database
18 - MySQL programming
19 header-includes:
20 - \usepackage{latex/packages}
21 ---
22
23 <!--
24 pandoc temp.md --pdf-engine=xelatex --toc --filter pandoc-numbering --filter pandoc-citeproc --top-level-division=chapter -M date="`date "+%B %e, %Y"`" -o temp.pdf
25 pandoc temp.md --pdf-engine=xelatex --toc --filter pandoc-numbering --filter pandoc-citeproc --top-level-division=chapter -M date="`date "+%B %e, %Y"`" -s -o temp.html
26 -->
27
28
29 # Bla
30
31 ## Problem
32
33 Problem (Creating and using a simple table in SQL) +.#address
34
35 Question -.#
36 ~ Log in as `testuser`, create a database named `HW_Address`, use it, and create two tables:
37
38 ~~~{.sqlmysql .numberLines}
39 CREATE TABLE NAME(
40 FName VARCHAR(15),
41 LName VARCHAR(15),
42 Id INT,
43 PRIMARY KEY(Id)
44 );
45
46 CREATE TABLE ADDRESS(
47 StreetName VARCHAR(15),
48 Number INT,
49 Habitants INT,
50 PRIMARY KEY(StreetName, Number)
51 );
52 ~~~
53
54 Question -.#
55 ~ Observe the output produced by the command
56
57 ~~~{.sqlmysql}
58 DESC ADDRESS;
59 ~~~
60
61 Question -.#
62 ~ Add a foreign key to the `ADDRESS` table, using
63
64 ~~~{.sqlmysql}
65 ALTER TABLE ADDRESS
66 ADD FOREIGN KEY (Habitants)
67 REFERENCES NAME(Id);
68 ~~~
69
70 And observe the new output produced by the command
71
72 ~~~{.sqlmysql}
73 DESC ADDRESS;
74 ~~~
75
76 Is it what you would have expected? How informative is it? Can you think of a command that would output more detailled information, including a reference to the existence of the foreign key?
77
78 Question -.#
79 ~ Draw the relational model corresponding to that database, including the primary, as well as foreign, keys.
80
81 Question -.#
82 ~ Add some data in the `NAME` table:
83
84 ~~~{.sqlmysql}
85 INSERT INTO NAME VALUES ('Barbara', 'Liskov', 003);
86 INSERT INTO NAME VALUES ('Tuong Lu', 'Kim', 004);
87 INSERT INTO NAME VALUES ('Samantha', NULL, 080);
88 ~~~
89
90 What command can you use to display this infomation back?
91 Do you notice anything regarding the values we entered for the `Id` attribute?
92
93 Question -.#
94 ~ Add some data into the `ADDRESS` table:
95
96 ~~~{.sqlmysql}
97 INSERT INTO ADDRESS
98 VALUES
99 ('Armstrong Drive', 10019, 003),
100 ('North Broad St.', 23, 004),
101 ('Robert Lane', 120, NULL);
102 ~~~
103
104 What difference do you note with the insertions we made in the `NAME` table. Which syntax seem more easy to you?
105
106 Question -.#
107 ~ Write a `SELECT` statement that returns the `Id` number of the person whose first name is "Samantha".
108
109 Question -.#
110 ~ Write a statement that violate the entity integrity constraint. What is the error message returned?
111
112 Question -.#
113 ~ Execute an `UPDATE` statement that violate the referential integrity constraint. What is the error message returned?
114
115 Question -.#
116 ~ Write a statement that violate another kind of constraint. Explain what constraint you are violating, and explain the error message.
117
118
119 Problem (Duplicate rows in SQL) +.#repetition
120
121 Log in as `testuser` and create a database `HW_REPETITION`.
122 Create in that database a table (I will assume you named it `EXAMPLE` in the following, but you are free to name it the way you want) with at least two attributes that have different data types. Don't declare a primary key yet. Answer the following:
123
124 @problem:repetition -- Question -.#
125 ~ Add a tuple to your table using
126
127
128 [Pb T %T t %t D %D d %d s %s g %g c %c p %p n %n \# #](#problem:repetition "caption") -- Question -.#
129 ~ Add a tuple to your table using
130
131
132 [Pb T %T t %t D %D d %d s %s g %g c %c p %p n %n \# #](#problem:repetition "caption") -- Question -.#
133 ~ Add a tuple to your table using
134
135
136 [Pb %s.%c ](#problem:repetition "caption") -- Question -.#
137 ~ Add a tuple to your table using
138
139
140 [Pb %s.%c](#problem:repetition "caption") -- Question -.#
141 ~ Add a tuple to your table using
142
143 [Problem %g](#problem:repetition) -- Question -.#
144
145 1.2
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