File notes/lectures_notes.md changed (mode: 100644) (index 0226c58..bf00f98) |
... |
... |
To give you a sense of what you will be asked to do during the exams, please fin |
111 |
111 |
The source code for those notes is hosted at [rocketgit](https://rocketgit.com/user/caubert/CSCI_3410), typeset in markdown, and then compiled using [pandoc](http://pandoc.org/) and two filters, [pandoc-numbering](https://github.com/chdemko/pandoc-numbering) and [pandoc-citeproc](https://github.com/jgm/pandoc-citeproc). |
The source code for those notes is hosted at [rocketgit](https://rocketgit.com/user/caubert/CSCI_3410), typeset in markdown, and then compiled using [pandoc](http://pandoc.org/) and two filters, [pandoc-numbering](https://github.com/chdemko/pandoc-numbering) and [pandoc-citeproc](https://github.com/jgm/pandoc-citeproc). |
112 |
112 |
The document uses [Linux Libertine fonts](http://libertine-fonts.org/), and the drawings use various [LaTeX](https://www.latex-project.org/) packages, including [PGF, TikZ](https://sourceforge.net/projects/pgf/) and [tikz-er2](https://bitbucket.org/pavel_calado/tikz-er2/raw/da9f9f7f169647cad6d91df7975400b1605ae67a/tikz-er2.sty). |
The document uses [Linux Libertine fonts](http://libertine-fonts.org/), and the drawings use various [LaTeX](https://www.latex-project.org/) packages, including [PGF, TikZ](https://sourceforge.net/projects/pgf/) and [tikz-er2](https://bitbucket.org/pavel_calado/tikz-er2/raw/da9f9f7f169647cad6d91df7975400b1605ae67a/tikz-er2.sty). |
113 |
113 |
The help from the [TeX - LaTeX Stack Exchange](https://tex.stackexchange.com/) community greatly improved this document. |
The help from the [TeX - LaTeX Stack Exchange](https://tex.stackexchange.com/) community greatly improved this document. |
|
114 |
|
The u͟n͟d͟e͟r͟l͟i͟n͟e͟ text is obtained from <https://yaytext.com/underline/>, the unicode symbols are searched in <http://milde.users.sourceforge.net/LUCR/Math/unimathsymbols.html>. |
114 |
115 |
|
|
115 |
116 |
To clone and compile this document, refer to the `README.md` file, at <https://rocketgit.com/user/caubert/CSCI_3410/source/tree/branch/master/blob/README.md> or <http://spots.augusta.edu/caubert/teaching/2019/spring/csci3410/CSCI_3410_2019_F_README.html>. |
To clone and compile this document, refer to the `README.md` file, at <https://rocketgit.com/user/caubert/CSCI_3410/source/tree/branch/master/blob/README.md> or <http://spots.augusta.edu/caubert/teaching/2019/spring/csci3410/CSCI_3410_2019_F_README.html>. |
116 |
117 |
|
|
|
... |
... |
Tuples can't be equal, so a subset of values must distinguish them, we study the |
484 |
485 |
|
|
485 |
486 |
- A **superkey** is the subset of attributes SK is a superkey for the relation R, if for all relation state r of R, all tuples t$_1$, t$_2$ in r are such that t$_1$[SK] $\neq$ t$_2$[SK]. |
- A **superkey** is the subset of attributes SK is a superkey for the relation R, if for all relation state r of R, all tuples t$_1$, t$_2$ in r are such that t$_1$[SK] $\neq$ t$_2$[SK]. |
486 |
487 |
- A **key** is a minimal superkey (i.e., removing any attribute from SK would break the uniqueness property). |
- A **key** is a minimal superkey (i.e., removing any attribute from SK would break the uniqueness property). |
487 |
|
- A **candidate key** is a key, a **primary key** is the selected candidate key (it is underlined). |
|
|
488 |
|
- 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.]). |
488 |
489 |
|
|
489 |
490 |
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! |
490 |
491 |
|
|
|
... |
... |
Aransaction is a series of retrievals and updates performed by an application pr |
545 |
546 |
|
|
546 |
547 |
### Insert / Delete / Update |
### Insert / Delete / Update |
547 |
548 |
|
|
548 |
|
(a.), (b.) and (c.) refers to the "remedies", discussed in the next section. |
|
|
549 |
|
(1.), (2.) and (3.) refers to the "remedies", discussed in the next section. |
549 |
550 |
|
|
550 |
551 |
#### Insert |
#### Insert |
551 |
552 |
|
|
|
... |
... |
Aransaction is a series of retrievals and updates performed by an application pr |
553 |
554 |
|
|
554 |
555 |
How things can go wrong: |
How things can go wrong: |
555 |
556 |
|
|
556 |
|
- `NULL` for the primary key (a.) |
|
557 |
|
- Duplicate value for the primary key (a.) |
|
558 |
|
- Wrong number of arguments (a.) |
|
559 |
|
- Fail to reference an existing value for a foreign key (a.) |
|
|
557 |
|
- `NULL` for the primary key (1.) |
|
558 |
|
- Duplicate value for the primary key (1.) |
|
559 |
|
- Wrong number of arguments (1.) |
|
560 |
|
- Fail to reference an existing value for a foreign key (1.) |
560 |
561 |
|
|
561 |
562 |
#### Delete |
#### Delete |
562 |
563 |
|
|
|
... |
... |
How things can go wrong: |
573 |
574 |
|
|
574 |
575 |
How things can go wrong: |
How things can go wrong: |
575 |
576 |
|
|
576 |
|
- Duplicate value for the primary key (a.) |
|
577 |
|
- `NULL` for the primary key (a.) |
|
|
577 |
|
- Duplicate value for the primary key (1.) |
|
578 |
|
- `NULL` for the primary key (1.) |
578 |
579 |
- Change value that are referenced (a., b., c.) |
- Change value that are referenced (a., b., c.) |
579 |
|
- Change foreign key to a non-existing value (a.) |
|
|
580 |
|
- Change foreign key to a non-existing value (1.) |
580 |
581 |
|
|
581 |
582 |
|
|
582 |
583 |
### Dealing with violations |
### Dealing with violations |
|
... |
... |
Row • | | • Attribute |
598 |
599 |
Column header • | | • Tuple |
Column header • | | • Tuple |
599 |
600 |
Table • | | • Relation |
Table • | | • Relation |
600 |
601 |
|
|
601 |
|
<!-- Bogue, on ne peut avoir les tables inline. --> |
|
602 |
|
|
|
603 |
602 |
Exercise +.# |
Exercise +.# |
604 |
603 |
~ What do we call the number of attributes in a relation? |
~ What do we call the number of attributes in a relation? |
605 |
604 |
|
|
|
... |
... |
Exercise +.# |
2118 |
2117 |
|
|
2119 |
2118 |
## Solution to Exercises {-} |
## Solution to Exercises {-} |
2120 |
2119 |
|
|
2121 |
|
Solution +.# |
|
2122 |
|
~ It can specify the conceptual and internal schema, **and** it can manipulate the data. |
|
|
2120 |
|
Solution +.# |
2123 |
2121 |
|
|
2124 |
|
Solution +.# |
|
2125 |
|
~ Database (schema), table, view, assertion, trigger, etc. |
|
|
2122 |
|
: It can specify the conceptual and internal schema, **and** it can manipulate the data. |
2126 |
2123 |
|
|
2127 |
|
Solution +.# |
|
2128 |
|
~ \ |
|
|
2124 |
|
Solution +.# |
2129 |
2125 |
|
|
2130 |
|
~~~{.sqlmysql} |
|
2131 |
|
ALTER TABLE STAFF ADD PRIMARY KEY(Id); |
|
2132 |
|
~~~ |
|
|
2126 |
|
: Database (schema), table, view, assertion, trigger, etc. |
|
2127 |
|
|
|
2128 |
|
Solution +.# |
|
2129 |
|
|
|
2130 |
|
: `ALTER TABLE STAFF ADD PRIMARY KEY(Id);`{.sqlmysql} |
2133 |
2131 |
|
|
2134 |
2132 |
Solution +.# |
Solution +.# |
2135 |
2133 |
|
|
2136 |
2134 |
<!-- Bogue, on ne peut avoir les tables inline. --> |
<!-- Bogue, on ne peut avoir les tables inline. --> |
2137 |
2135 |
|
|
2138 |
|
Data type | Examples | |
|
|
2136 |
|
Data type | Examples |
|
2137 |
|
--- | --- |
2139 |
2138 |
Int | `4`, `-32` |
Int | `4`, `-32` |
2140 |
2139 |
Char(4) | `'trai'`, `'plol'` |
Char(4) | `'trai'`, `'plol'` |
2141 |
2140 |
VarChar(10) | `'Train'`, `'Michelle'` |
VarChar(10) | `'Train'`, `'Michelle'` |
|
... |
... |
Bit(4) | `B'1010'`, `B'0101'` |
2143 |
2142 |
Boolean | `TRUE`, `UNKNOWN` |
Boolean | `TRUE`, `UNKNOWN` |
2144 |
2143 |
|
|
2145 |
2144 |
Solution +.# |
Solution +.# |
2146 |
|
~ That we can store exactly three characters. |
|
2147 |
2145 |
|
|
2148 |
|
Solution +.# |
|
2149 |
|
~ It creates a schema, i.e., a database, named `Faculty`. |
|
|
2146 |
|
: That we can store exactly three characters. |
|
2147 |
|
|
|
2148 |
|
Solution +.# |
|
2149 |
|
|
|
2150 |
|
: It creates a schema, i.e., a database, named `Faculty`{.sqlmysql}. |
2150 |
2151 |
|
|
2151 |
2152 |
Solution +.# |
Solution +.# |
2152 |
|
~ It removes the `UNIQUE` constraint on the `Attribute1` in the `TABLEA` table. |
|
|
2153 |
|
|
|
2154 |
|
: It removes the `UNIQUE`{.sqlmysql} constraint on the `Attribute1`{.sqlmysql} in the `TABLEA`{.sqlmysql} table. |
2153 |
2155 |
|
|
2154 |
|
Solution +.# |
|
2155 |
|
~ `DATE'2016-01-21'`, `'2016-01-21'`, `'2016/01/21'`, `'20160121'`. |
|
|
2156 |
|
Solution +.# |
|
2157 |
|
|
|
2158 |
|
: `DATE'2016-01-21'`{.sqlmysql}, `'2016-01-21'`{.sqlmysql}, `'2016/01/21'`{.sqlmysql}, `'20160121'`{.sqlmysql}. |
2156 |
2159 |
|
|
2157 |
|
Solution +.# |
|
2158 |
|
~ \ |
|
|
2160 |
|
Solution +.# |
2159 |
2161 |
|
|
2160 |
|
~~~{.sqlmysql} |
|
2161 |
|
INSERT INTO TRAINS VALUES('Thomas', 4); |
|
2162 |
|
~~~ |
|
|
2162 |
|
: `INSERT INTO TRAINS VALUES('Thomas', 4);`{.sqlmysql} |
2163 |
2163 |
|
|
2164 |
|
Solution +.# |
|
2165 |
|
~ Yes. |
|
|
2164 |
|
Solution +.# |
|
2165 |
|
|
|
2166 |
|
: Yes. |
2166 |
2167 |
|
|
2167 |
|
Solution +.# |
|
2168 |
|
~ [@Textbook6, pp. 67--69] or [@Textbook7, pp. 157--158] reads: |
|
|
2168 |
|
Solution +.# |
|
2169 |
|
~ |
|
2170 |
|
[@Textbook6, pp. 67--69] or [@Textbook7, pp. 157--158] reads: |
2169 |
2171 |
|
|
2170 |
2172 |
> Constraints on databases can generally be divided into three main categories: |
> Constraints on databases can generally be divided into three main categories: |
2171 |
|
> |
|
2172 |
|
>#. Constraints that are inherent in the data model. We call these **inherent model-based constraints** or **implicit constraints**. |
|
2173 |
|
>#. Constraints that can be directly expressed in schemas of the data model, typically by specifying them in the DDL (data definition language, see Section 2.3.1). We call these **schema-based constraints** or **explicit constraints**. |
|
2174 |
|
>#. Constraints that *cannot* be directly expressed in the schemas of the data model, and hence must be expressed and enforced by the application programs. We call these **application-based** or **semantic constraints** or **business rules**. |
|
|
2173 |
|
> |
|
2174 |
|
>#. Constraints that are inherent in the data model. We call these **inherent model-based constraints** or **implicit constraints**. |
|
2175 |
|
>#. Constraints that can be directly expressed in schemas of the data model, typically by specifying them in the DDL (data definition language, see Section 2.3.1). We call these **schema-based constraints** or **explicit constraints**. |
|
2176 |
|
>#. Constraints that *cannot* be directly expressed in the schemas of the data model, and hence must be expressed and enforced by the application programs. We call these **application-based** or **semantic constraints** or **business rules**. |
2175 |
2177 |
|
|
|
2178 |
|
Solution +.# |
2176 |
2179 |
|
|
2177 |
|
Solution +.# |
|
2178 |
|
~ A forein key is an attribute (or column, field) referencing another attribute, which must be part of a primary key. It establishes connection between tables. |
|
|
2180 |
|
: A forein key is an attribute (or column, field) referencing another attribute, which must be part of a primary key. It establishes connection between tables. |
2179 |
2181 |
|
|
2180 |
|
Solution +.# |
|
2181 |
|
~ We should use a referential triggered action clause, |
|
|
2182 |
|
Solution +.# |
2182 |
2183 |
|
|
2183 |
|
~~~{.sqlmysql} |
|
2184 |
|
ON DELETE CASCADE |
|
2185 |
|
~~~ |
|
|
2184 |
|
: We should use a referential triggered action clause, : `ON DELETE CASCADE`{.sqlmysql}. |
|
2185 |
|
|
|
2186 |
|
Solution +.# |
2186 |
2187 |
|
|
2187 |
|
Solution +.# |
|
2188 |
|
~ If the referenced row is updated, then the attribute of the referencing rows are set to `NULL`. |
|
|
2188 |
|
: If the referenced row is updated, then the attribute of the referencing rows are set to `NULL`{.sqlmysql}. |
2189 |
2189 |
|
|
2190 |
|
Solution +.# |
|
2191 |
|
~ In the referencing rows, |
|
2192 |
|
|
|
|
2190 |
|
Solution +.# |
|
2191 |
|
~ |
|
2192 |
|
In the referencing rows, |
|
2193 |
|
|
2193 |
2194 |
#. the department number is set to the default value. |
#. the department number is set to the default value. |
2194 |
2195 |
#. the department number is updated accordingly. |
#. the department number is updated accordingly. |
2195 |
2196 |
|
|
2196 |
|
Solution +.# |
|
|
2197 |
|
Solution +.# |
2197 |
2198 |
~ |
~ |
2198 |
|
|
|
2199 |
|
#. This operation is rejected: the row in the `DEPARTMENT` table with primary key `Number` set to `3` can't be deleted if a row in the `WORKER` table references it. |
|
|
2199 |
|
#. This operation is rejected: the row in the `DEPARTMENT`{.sqlmysql} table with primary key `Number`{.sqlmysql} set to `3`{.sqlmysql} can't be deleted if a row in the `WORKER`{.sqlmysql} table references it. |
2200 |
2200 |
#. In the referencing rows, the department number is updated accordingly. |
#. In the referencing rows, the department number is updated accordingly. |
2201 |
2201 |
|
|
2202 |
|
Solution +.# |
|
|
2202 |
|
Solution +.# |
2203 |
2203 |
~ \ |
~ \ |
2204 |
|
|
|
2205 |
2204 |
~~~{.sqlmysql} |
~~~{.sqlmysql} |
2206 |
2205 |
SELECT Name, Address |
SELECT Name, Address |
2207 |
2206 |
FROM TOURIST |
FROM TOURIST |
2208 |
2207 |
WHERE EntryDate > DATE'2012-09-15'; |
WHERE EntryDate > DATE'2012-09-15'; |
2209 |
2208 |
~~~ |
~~~ |
2210 |
2209 |
|
|
2211 |
|
Solution +.# |
|
2212 |
|
~ It selects all the attributes. |
|
|
2210 |
|
Solution +.# |
|
2211 |
|
|
|
2212 |
|
: It selects all the attributes. |
|
2213 |
|
|
|
2214 |
|
Solution +.# |
|
2215 |
|
|
|
2216 |
|
: The name of the relation with the name of its schema and a period beforehand. An example would be `EMPLOYEE.Name`{.sqlmysql}. |
|
2217 |
|
|
|
2218 |
|
Solution +.# |
2213 |
2219 |
|
|
2214 |
|
Solution +.# |
|
2215 |
|
~ The name of the relation with the name of its schema and a period beforehand. An example would be `EMPLOYEE.Name`. |
|
|
2220 |
|
: All the tables in that database. |
2216 |
2221 |
|
|
2217 |
|
Solution +.# |
|
2218 |
|
~ All the tables in that database. |
|
|
2222 |
|
Solution +.# |
2219 |
2223 |
|
|
2220 |
|
Solution +.# |
|
2221 |
|
~ A set where the same value can occur twice. The same row can occur twice in a table. |
|
|
2224 |
|
: A set where the same value can occur twice. The same row can occur twice in a table. |
2222 |
2225 |
|
|
2223 |
|
Solution +.# |
|
2224 |
|
~ They both select all the rows in the `MYTABLE` table, but `ALL` will print the duplicate values, whereas `DISTINCT` will print them only once. |
|
|
2226 |
|
Solution +.# |
2225 |
2227 |
|
|
|
2228 |
|
: They both select all the rows in the `MYTABLE`{.sqlmysql} table, but `ALL`{.sqlmysql} will print the duplicate values, whereas `DISTINCT`{.sqlmysql} will print them only once. |
|
2229 |
|
|
|
2230 |
|
Solution +.# |
|
2231 |
|
|
|
2232 |
|
: You can't have the `WHERE`{.sqlmysql} before `FROM`{.sqlmysql}. |
|
2233 |
|
|
|
2234 |
|
Solution +.# |
2226 |
2235 |
|
|
2227 |
|
Solution +.# |
|
2228 |
|
~ You can't have the `WHERE` before `FROM`. |
|
|
2236 |
|
: `SELECT COUNT(*) FROM BOOK;`{.sqlmysql} |
2229 |
2237 |
|
|
2230 |
|
Solution +.# |
|
2231 |
|
~ `SELECT COUNT(*) FROM BOOK;` |
|
|
2238 |
|
Solution +.# |
2232 |
2239 |
|
|
2233 |
|
Solution +.# |
|
2234 |
|
~ We use those query that projects on attributes using a selection and join conditions when we need to construct for information based on pieces of data spread in multiple tables. |
|
|
2240 |
|
: We use those query that projects on attributes using a selection and join conditions when we need to construct for information based on pieces of data spread in multiple tables. |
2235 |
2241 |
|
|
2236 |
|
Solution +.# |
|
2237 |
|
~ It makes the distinction between two different rows of the same table, it is useful when we want to select a tuple in a relation that is in a particular relation with a tuple in the same relation. Quoting <https://stackoverflow.com/a/7698796/>: |
|
|
2242 |
|
Solution +.# |
|
2243 |
|
~ |
|
2244 |
|
It makes the distinction between two different rows of the same table, it is useful when we want to select a tuple in a relation that is in a particular relation with a tuple in the same relation. Quoting <https://stackoverflow.com/a/7698796/>: |
2238 |
2245 |
|
|
2239 |
2246 |
> They are useful for saving typing, but there are other reasons to use them: |
> They are useful for saving typing, but there are other reasons to use them: |
2240 |
2247 |
> |
> |
2241 |
2248 |
> - If you join a table to itself you must give it two different names otherwise referencing the table would be ambiguous. |
> - If you join a table to itself you must give it two different names otherwise referencing the table would be ambiguous. |
2242 |
2249 |
> - It can be useful to give names to derived tables, and in some database systems it is required… even if you never refer to the name. |
> - It can be useful to give names to derived tables, and in some database systems it is required… even if you never refer to the name. |
2243 |
2250 |
|
|
2244 |
|
Solution +.# |
|
|
2251 |
|
Solution +.# |
2245 |
2252 |
~ \ |
~ \ |
2246 |
|
|
|
|
2253 |
|
|
2247 |
2254 |
~~~{.sqlmysql} |
~~~{.sqlmysql} |
2248 |
2255 |
UPDATE PROF SET Name = 'Hugo Pernot' |
UPDATE PROF SET Name = 'Hugo Pernot' |
2249 |
2256 |
WHERE Login = 'caubert'; |
WHERE Login = 'caubert'; |
2250 |
2257 |
~~~ |
~~~ |
2251 |
2258 |
|
|
2252 |
|
Solution +.# |
|
2253 |
|
~ Yes, we could update more than one tuple at a time. |
|
|
2259 |
|
Solution +.# |
|
2260 |
|
|
|
2261 |
|
: Yes, we could update more than one tuple at a time. |
2254 |
2262 |
|
|
2255 |
|
Solution +.# |
|
2256 |
|
~ Unknown value, unavailable / withheld, N/A. |
|
|
2263 |
|
Solution +.# |
2257 |
2264 |
|
|
2258 |
|
Solution +.# |
|
|
2265 |
|
: Unknown value, unavailable / withheld, N/A. |
|
2266 |
|
|
|
2267 |
|
Solution +.# |
2259 |
2268 |
~ |
~ |
2260 |
2269 |
|
|
2261 |
|
- `TRUE AND FALSE` → `FALSE` |
|
2262 |
|
- `TRUE AND UNKNOWN` → `UNKNOWN` |
|
2263 |
|
- `NOT UNKNOWN` → `UNKNOWN` |
|
2264 |
|
- `FALSE OR UNKNOWN` → `FALSE` |
|
|
2270 |
|
- `TRUE AND FALSE`{.sqlmysql} → `FALSE`{.sqlmysql} |
|
2271 |
|
- `TRUE AND UNKNOWN`{.sqlmysql} → `UNKNOWN`{.sqlmysql} |
|
2272 |
|
- `NOT UNKNOWN`{.sqlmysql} → `UNKNOWN`{.sqlmysql} |
|
2273 |
|
- `FALSE OR UNKNOWN`{.sqlmysql} → `FALSE`{.sqlmysql} |
2265 |
2274 |
|
|
2266 |
2275 |
|
|
2267 |
|
Solution +.# |
|
2268 |
|
~ `IS NOT` |
|
|
2276 |
|
Solution +.# |
|
2277 |
|
|
|
2278 |
|
: `IS NOT`{.sqlmysql} |
2269 |
2279 |
|
|
2270 |
|
Solution +.# |
|
2271 |
|
~ It list the login of the professors teaching in the department where the student whose login is "jrakesh" is majoring. It can be rewritten as |
|
|
2280 |
|
Solution +.# |
|
2281 |
|
~ |
|
2282 |
|
It list the login of the professors teaching in the department where the student whose login is "jrakesh" is majoring. It can be rewritten as |
2272 |
2283 |
|
|
2273 |
2284 |
~~~{.sqlmysql} |
~~~{.sqlmysql} |
2274 |
2285 |
SELECT PROF.Login |
SELECT PROF.Login |
|
... |
... |
Solution +.# |
2277 |
2288 |
AND STUDENT.Login = 'jrakesh'; |
AND STUDENT.Login = 'jrakesh'; |
2278 |
2289 |
~~~ |
~~~ |
2279 |
2290 |
|
|
2280 |
|
Solution +.# |
|
2281 |
|
~ It tries to find a `Login` in a `Code`! |
|
|
2291 |
|
Solution +.# |
|
2292 |
|
|
|
2293 |
|
: It tries to find a `Login`{.sqlmysql} in a `Code`{.sqlmysql}. |
|
2294 |
|
|
|
2295 |
|
Solution +.# |
|
2296 |
|
|
|
2297 |
|
: `SELECT SUM(Pages) FROM BOOK;`{.sqlmysql} |
|
2298 |
|
|
|
2299 |
|
Solution +.# |
2282 |
2300 |
|
|
2283 |
|
Solution +.# |
|
2284 |
|
~ `SELECT SUM(Pages) FROM BOOK;` |
|
|
2301 |
|
: `ALTER TABLE BOOK ADD COLUMN Pages INT;`{.sqlmysql} |
2285 |
2302 |
|
|
2286 |
|
Solution +.# |
|
2287 |
|
~ `ALTER TABLE BOOK ADD COLUMN Pages INT;` |
|
|
2303 |
|
Solution +.# |
2288 |
2304 |
|
|
2289 |
|
Solution +.# |
|
2290 |
|
~ `ALTER TABLE BOOK ALTER COLUMN Pages DROP DEFAULT;` |
|
|
2305 |
|
: `ALTER TABLE BOOK ALTER COLUMN Pages DROP DEFAULT;`{.sqlmysql} |
2291 |
2306 |
|
|
2292 |
2307 |
|
|
2293 |
2308 |
## Problems {-} |
## Problems {-} |
|
... |
... |
Exercise +.# |
4086 |
4101 |
Exercise +.# |
Exercise +.# |
4087 |
4102 |
~ Consider the following relation: |
~ Consider the following relation: |
4088 |
4103 |
|
|
4089 |
|
PROF(\underline{SSN}, Name, Department, Bike\_brand) |
|
|
4104 |
|
PROF(S͟S͟N͟, Name, Department, Bike\_brand) |
4090 |
4105 |
|
|
4091 |
4106 |
Why is it a poor design to have a "Bike\_brand" attribute in such a relation? |
Why is it a poor design to have a "Bike\_brand" attribute in such a relation? |
4092 |
4107 |
How should we store this information? |
How should we store this information? |
|
... |
... |
Exercise +.# |
4094 |
4109 |
Exercise +.# |
Exercise +.# |
4095 |
4110 |
~ Consider the following relation: |
~ Consider the following relation: |
4096 |
4111 |
|
|
4097 |
|
STUDENT(\underline{SSN}, Name, $…$, Sibling\_On\_Campus) |
|
|
4112 |
|
STUDENT(S͟S͟N͟, Name, $…$, Sibling\_On\_Campus) |
4098 |
4113 |
|
|
4099 |
4114 |
Why is it a poor design to have a "Sibling\_On\_Campus" attribute in such a relation? |
Why is it a poor design to have a "Sibling\_On\_Campus" attribute in such a relation? |
4100 |
4115 |
How should we store this information? |
How should we store this information? |
|
... |
... |
Exercise +.# |
4102 |
4117 |
Exercise +.# |
Exercise +.# |
4103 |
4118 |
~ Consider the following relational database schema: |
~ Consider the following relational database schema: |
4104 |
4119 |
|
|
4105 |
|
STUDENT(\underline{Login}, Name, $…$, Major, Major\_Head) |
|
4106 |
|
DEPARTMENT(\underline{Code}, Name, Major\_Head) |
|
|
4120 |
|
STUDENT(L͟o͟g͟i͟n͟, Name, $…$, Major, Major\_Head) |
|
4121 |
|
DEPARTMENT(C͟o͟d͟e͟, Name, Major\_Head) |
4107 |
4122 |
|
|
4108 |
4123 |
Assuming that "Major" is a foreign key referencing "DEPARTMENT.Code", what is the problem with that schema? How could you address it? |
Assuming that "Major" is a foreign key referencing "DEPARTMENT.Code", what is the problem with that schema? How could you address it? |
4109 |
4124 |
|
|
|
... |
... |
Exercise +.# |
4209 |
4224 |
|
|
4210 |
4225 |
## Solution to Exercises {-} |
## Solution to Exercises {-} |
4211 |
4226 |
|
|
4212 |
|
Solution +.# |
|
4213 |
|
~ Name / extension. |
|
|
4227 |
|
Solution +.# |
|
4228 |
|
|
|
4229 |
|
: Name / extension. |
4214 |
4230 |
To have statistics about the extensions, to sort the username by length, etc. |
To have statistics about the extensions, to sort the username by length, etc. |
4215 |
4231 |
|
|
4216 |
|
Solution +.# |
|
4217 |
|
~ { width=100% } |
|
4218 |
|
\ |
|
|
4232 |
|
Solution +.# |
4219 |
4233 |
|
|
4220 |
|
Solution +.# |
|
4221 |
|
~ { width=100% } |
|
4222 |
|
\ |
|
|
4234 |
|
: { width=100% } |
|
4235 |
|
|
|
4236 |
|
Solution +.# |
|
4237 |
|
|
|
4238 |
|
: { width=100% } |
|
4239 |
|
|
|
4240 |
|
Solution +.# |
4223 |
4241 |
|
|
|
4242 |
|
: There can be more than one key in the ER model. |
4224 |
4243 |
|
|
4225 |
|
Solution +.# |
|
4226 |
|
~ There can be more than one key in the ER model. |
|
|
4244 |
|
Solution +.# |
|
4245 |
|
|
|
4246 |
|
: The weak entity type doesn't have a primary key. |
|
4247 |
|
|
|
4248 |
|
Solution +.# |
4227 |
4249 |
|
|
4228 |
|
Solution +.# |
|
4229 |
|
~ The weak entity type doesn't have a primary key. |
|
|
4250 |
|
: The number of participating entity types. |
4230 |
4251 |
|
|
4231 |
|
Solution +.# |
|
4232 |
|
~ The number of participating entity types. |
|
|
4252 |
|
Solution +.# |
4233 |
4253 |
|
|
4234 |
|
Solution +.# |
|
4235 |
|
~ A relationship type where the same entity type participates more than once. |
|
|
4254 |
|
: A relationship type where the same entity type participates more than once. |
4236 |
4255 |
On rooms, "is to the left of", on persons, "is married to". |
On rooms, "is to the left of", on persons, "is married to". |
4237 |
4256 |
|
|
4238 |
|
Solution +.# |
|
4239 |
|
~ That a person can own multiple computers, and that a computer can have multiple owners. |
|
|
4257 |
|
Solution +.# |
|
4258 |
|
|
|
4259 |
|
: That a person can own multiple computers, and that a computer can have multiple owners. |
|
4260 |
|
|
|
4261 |
|
Solution +.# |
|
4262 |
|
|
|
4263 |
|
: Cardinality ration and participation constraints. |
|
4264 |
|
|
|
4265 |
|
Solution +.# |
4240 |
4266 |
|
|
4241 |
|
Solution +.# |
|
4242 |
|
~ Cardinality ration and participation constraints. |
|
|
4267 |
|
: When the cardinality is $1:N$, $1:1$ or $N:1$. |
4243 |
4268 |
|
|
4244 |
|
Solution +.# |
|
4245 |
|
~ When the cardinality is $1:N$, $1:1$ or $N:1$. |
|
|
4269 |
|
Solution +.# |
4246 |
4270 |
|
|
4247 |
|
Solution +.# |
|
4248 |
|
~ For a weak entity attribute, it is the attribute that can uniquely identify weak entites that are related to the same owner entity. |
|
|
4271 |
|
: For a weak entity attribute, it is the attribute that can uniquely identify weak entites that are related to the same owner entity. |
4249 |
4272 |
|
|
4250 |
|
Solution +.# |
|
|
4273 |
|
Solution +.# |
4251 |
4274 |
|
|
4252 |
4275 |
Entity 1 | Cardinality Ratio | Entity 2 | Explanation | |
Entity 1 | Cardinality Ratio | Entity 2 | Explanation | |
4253 |
4276 |
| --- | :---: | --- | --------| |
| --- | :---: | --- | --------| |
|
... |
... |
COMPUTER | $M:N$ | OS| "A computer can have multiple operating system, the same |
4259 |
4282 |
|
|
4260 |
4283 |
Some of those choices, of course, are is arguable (typically, almost any combination seems reasonnable for the INSTRUCTOR : OFFICE relation). |
Some of those choices, of course, are is arguable (typically, almost any combination seems reasonnable for the INSTRUCTOR : OFFICE relation). |
4261 |
4284 |
|
|
4262 |
|
Solution +.# |
|
4263 |
|
~ SUPERVISION, a recursive relationship on EMPLOYEE. |
|
|
4285 |
|
Solution +.# |
4264 |
4286 |
|
|
4265 |
|
Solution +.# |
|
4266 |
|
~ { width=100% } |
|
4267 |
|
\ |
|
|
4287 |
|
: SUPERVISION, a recursive relationship on EMPLOYEE. |
4268 |
4288 |
|
|
|
4289 |
|
Solution +.# |
|
4290 |
|
|
|
4291 |
|
: { width=100% } |
4269 |
4292 |
|
|
4270 |
4293 |
Solution +.# |
Solution +.# |
4271 |
|
~ { width=100% } |
|
4272 |
|
\ |
|
4273 |
4294 |
|
|
4274 |
|
Solution +.# |
|
4275 |
|
~ { width=100% } |
|
4276 |
|
\ |
|
|
4295 |
|
: { width=100% } |
4277 |
4296 |
|
|
4278 |
|
Solution +.# |
|
4279 |
|
~ Same as before? |
|
4280 |
4297 |
|
|
4281 |
|
Solution +.# |
|
4282 |
|
~ Otherwise, we couldn't identify entities in it without owner entity. |
|
|
4298 |
|
Solution +.# |
|
4299 |
|
|
|
4300 |
|
: { width=100% } |
4283 |
4301 |
|
|
4284 |
|
Solution +.# |
|
4285 |
|
~ When you have to invent a primary key or add a lot of `NULL` value to be able to add a tuple. I want to add a room in my DB, but the only place where rooms are listed are as an attribute on a Instructor table, so I have to "fake" an instructor to add a room. |
|
|
4302 |
|
Solution +.# |
4286 |
4303 |
|
|
4287 |
|
Solution +.# |
|
4288 |
|
~ A delete anomaly exists when certain attributes are lost because of the deletion of other attributes. |
|
|
4304 |
|
: Same as before? |
4289 |
4305 |
|
|
4290 |
|
Solution +.# |
|
4291 |
|
~ Because they waste space, and because they are ambiguous (N/A, or unknown, or not communicated?). No, it is necessary sometimes. |
|
|
4306 |
|
Solution +.# |
4292 |
4307 |
|
|
4293 |
|
Solution +.# |
|
4294 |
|
~ Because it will be `NULL` most of the time. In a separate table. |
|
|
4308 |
|
: Otherwise, we couldn't identify entities in it without owner entity. |
4295 |
4309 |
|
|
4296 |
|
Solution +.# |
|
4297 |
|
~ Because it will be `NULL` most of the time, and because students could have more than one sibling on campus. In a separate table. |
|
|
4310 |
|
Solution +.# |
4298 |
4311 |
|
|
4299 |
|
Solution +.# |
|
4300 |
|
~ Major\_Head will give update anomalies. By putting the Head of the department in the DEPARTMENT relation only, i.e., removing it from STUDENT. |
|
|
4312 |
|
: When you have to invent a primary key or add a lot of `NULL` value to be able to add a tuple. I want to add a room in my DB, but the only place where rooms are listed are as an attribute on a Instructor table, so I have to "fake" an instructor to add a room. |
4301 |
4313 |
|
|
4302 |
|
Solution +.# |
|
4303 |
|
~ #. $F$ |
|
4304 |
|
#. $\{A, B, E\}$ |
|
4305 |
|
#. $\{A, E\}$ |
|
|
4314 |
|
Solution +.# |
4306 |
4315 |
|
|
4307 |
|
Solution +.# |
|
4308 |
|
~ #. $\{A, C\}$, |
|
4309 |
|
#. $A \to F$ by $A \to D, D\to F$. |
|
|
4316 |
|
: A delete anomaly exists when certain attributes are lost because of the deletion of other attributes. |
4310 |
4317 |
|
|
4311 |
|
Solution +.# |
|
4312 |
|
~ #. Yes. $C$ and $D$ are non prime, and they fully depend on $\{A,B\}$. |
|
4313 |
|
#. No. $D$ is the only non prime, and it depends only on $A$. |
|
|
4318 |
|
Solution +.# |
4314 |
4319 |
|
|
4315 |
|
Solution +.# |
|
4316 |
|
~ #. $A,B,C$ |
|
4317 |
|
#. No, because we can remove $D$, |
|
4318 |
|
#. $A \to D$, $D \to E$ and $A \to E$ |
|
|
4320 |
|
: Because they waste space, and because they are ambiguous (N/A, or unknown, or not communicated?). No, it is necessary sometimes. |
4319 |
4321 |
|
|
4320 |
|
Solution +.# |
|
4321 |
|
~ #. $\{B, C\}$, $A$ |
|
4322 |
|
#. $A$, $\{C,E\}$, |
|
4323 |
|
#. $\{A, D, E\}$, $\{A, B, E\}$ |
|
|
4322 |
|
Solution +.# |
4324 |
4323 |
|
|
4325 |
|
Solution +.# |
|
4326 |
|
~ #. No. $C, D, E$, and $E$ has a partial relation to $B$ |
|
4327 |
|
#. Yes. Since the primary key is a singleton, it is obvious. |
|
|
4324 |
|
: Because it will be `NULL` most of the time. In a separate table. |
4328 |
4325 |
|
|
4329 |
|
Solution +.# |
|
4330 |
|
~ $\{B, D\} \to C \to F$ breaks the 3NF. |
|
|
4326 |
|
Solution +.# |
4331 |
4327 |
|
|
4332 |
|
Solution +.# |
|
4333 |
|
~ #. No. $B$, $C$ and $D$ are non prime, $A \to \{B,C\} \to D$ breaks the 3NF. |
|
4334 |
|
#. No. $A$, $B$ and $D$ are non prime, $B \to \{A,C\} \to D$ breaks the 3NF. |
|
|
4328 |
|
: Because it will be `NULL` most of the time, and because students could have more than one sibling on campus. In a separate table. |
4335 |
4329 |
|
|
4336 |
4330 |
Solution +.# |
Solution +.# |
4337 |
|
~ $\{A, B\}$, |
|
4338 |
4331 |
|
|
4339 |
|
$C, D, E$, |
|
|
4332 |
|
: Major\_Head will give update anomalies. By putting the Head of the department in the DEPARTMENT relation only, i.e., removing it from STUDENT. |
4340 |
4333 |
|
|
4341 |
|
$R_1(A, B, C, E)$ and $R_2(B, D)$ |
|
|
4334 |
|
Solution +.# |
|
4335 |
|
~ |
|
4336 |
|
#. $F$ |
|
4337 |
|
#. $\{A, B, E\}$ |
|
4338 |
|
#. $\{A, E\}$ |
|
4339 |
|
|
|
4340 |
|
Solution +.# |
|
4341 |
|
~ |
|
4342 |
|
#. $\{A, C\}$, |
|
4343 |
|
#. $A \to F$ by $A \to D, D\to F$. |
4342 |
4344 |
|
|
4343 |
|
$R_1(A, B, C)$, $R_2(C, E)$ and $R_3(B, D)$ |
|
|
4345 |
|
Solution +.# |
|
4346 |
|
~ |
|
4347 |
|
#. Yes. $C$ and $D$ are non prime, and they fully depend on $\{A,B\}$. |
|
4348 |
|
#. No. $D$ is the only non prime, and it depends only on $A$. |
4344 |
4349 |
|
|
4345 |
|
Solution +.# |
|
4346 |
|
~ Behaviour and structure |
|
|
4350 |
|
Solution +.# |
|
4351 |
|
~ |
|
4352 |
|
#. $A,B,C$ |
|
4353 |
|
#. No, because we can remove $D$, |
|
4354 |
|
#. $A \to D$, $D \to E$ and $A \to E$ |
4347 |
4355 |
|
|
4348 |
|
Solution +.# |
|
4349 |
|
~ Yes, U.M.L. diagram is language-independent and platform-independent. |
|
|
4356 |
|
Solution +.# |
|
4357 |
|
~ |
|
4358 |
|
#. $\{B, C\}$, $A$ |
|
4359 |
|
#. $A$, $\{C,E\}$, |
|
4360 |
|
#. $\{A, D, E\}$, $\{A, B, E\}$ |
4350 |
4361 |
|
|
4351 |
|
Solution +.# |
|
4352 |
|
~ #. Use-case |
|
4353 |
|
#. Sequence diagram |
|
4354 |
|
#. Activity diagram |
|
|
4362 |
|
Solution +.# |
|
4363 |
|
~ |
|
4364 |
|
#. No. $C, D, E$, and $E$ has a partial relation to $B$ |
|
4365 |
|
#. Yes. Since the primary key is a singleton, it is obvious. |
4355 |
4366 |
|
|
4356 |
|
Solution +.# |
|
4357 |
|
~ To use direction for association, to have a common language with someone less knowledgeable of other diagrammatic notations. |
|
4358 |
|
For the concept of integration. |
|
|
4367 |
|
Solution +.# |
4359 |
4368 |
|
|
4360 |
|
Solution +.# |
|
4361 |
|
~ $5$ and $4$. |
|
|
4369 |
|
: $\{B, D\} \to C \to F$ breaks the 3NF. |
4362 |
4370 |
|
|
4363 |
|
getLastFlightNumber() : Integer |
|
|
4371 |
|
Solution +.# |
|
4372 |
|
~ |
|
4373 |
|
#. No. $B$, $C$ and $D$ are non prime, $A \to \{B,C\} \to D$ breaks the 3NF. |
|
4374 |
|
#. No. $A$, $B$ and $D$ are non prime, $B \to \{A,C\} \to D$ breaks the 3NF. |
|
4375 |
|
|
|
4376 |
|
Solution +.# |
|
4377 |
|
~ |
|
4378 |
|
#. $\{A, B\}$, |
|
4379 |
|
|
|
4380 |
|
#. $C, D, E$, |
|
4381 |
|
|
|
4382 |
|
#. $R_1(A, B, C, E)$ and $R_2(B, D)$ |
|
4383 |
|
|
|
4384 |
|
#. $R_1(A, B, C)$, $R_2(C, E)$ and $R_3(B, D)$ |
|
4385 |
|
|
|
4386 |
|
Solution +.# |
|
4387 |
|
|
|
4388 |
|
: Behaviour and structure |
4364 |
4389 |
|
|
4365 |
|
stMaximumSpeed(MPH) : void |
|
|
4390 |
|
Solution +.# |
|
4391 |
|
|
|
4392 |
|
: Yes, U.M.L. diagram is language-independent and platform-independent. |
|
4393 |
|
|
|
4394 |
|
Solution +.# |
|
4395 |
|
~ |
|
4396 |
|
#. Use-case |
|
4397 |
|
#. Sequence diagram |
|
4398 |
|
#. Activity diagram |
|
4399 |
|
|
|
4400 |
|
Solution +.# |
|
4401 |
|
|
|
4402 |
|
: To use direction for association, to have a common language with someone less knowledgeable of other diagrammatic notations. |
|
4403 |
|
For the concept of integration. |
|
4404 |
|
|
|
4405 |
|
Solution +.# |
|
4406 |
|
~ |
|
4407 |
|
`Flight` has $5$ attributes, `Plane` has $4$. The `Plane` class could have the operations `getLastFlightNumber() : Integer` and `stMaximumSpeed(MPH) : void`. |
4366 |
4408 |
|
|
4367 |
|
A flight could be assigned to no plane, and a plane could not be assigned to a flight. |
|
|
4409 |
|
$0..*$: A flight could be assigned to no plane, and a plane could not be assigned to a flight. |
4368 |
4410 |
|
|
4369 |
|
A plane can be assigned to multiple (or no) flights, but a flight must have at most one plane (and could have none). |
|
|
4411 |
|
$0..1$: A plane can be assigned to multiple (or no) flights, but a flight must have at most one plane (and could have none). |
4370 |
4412 |
|
|
4371 |
|
Solution +.# |
|
|
4413 |
|
Solution +.# |
4372 |
4414 |
~ Aggregation: associated class can have an existence of its own. |
~ Aggregation: associated class can have an existence of its own. |
4373 |
4415 |
|
|
4374 |
4416 |
Composition association: class doesn't exist without the association. |
Composition association: class doesn't exist without the association. |
4375 |
4417 |
|
|
4376 |
|
Solution +.# |
|
|
4418 |
|
Solution +.# |
4377 |
4419 |
~  |
~  |
4378 |
4420 |
Because it avoids redundancy. |
Because it avoids redundancy. |
4379 |
4421 |
|
|
|
... |
... |
A driver has an id, an age, a name, and an address. |
4445 |
4487 |
|
|
4446 |
4488 |
One of the interesting choice is: should "accident" be an entity type or a relationship type? |
One of the interesting choice is: should "accident" be an entity type or a relationship type? |
4447 |
4489 |
|
|
4448 |
|
Solution +.# |
|
|
4490 |
|
Solution +.# |
4449 |
4491 |
~ \includegraphics[page=1,width=1\textwidth]{img/p.pdf} |
~ \includegraphics[page=1,width=1\textwidth]{img/p.pdf} |
4450 |
4492 |
|
|
4451 |
4493 |
OR |
OR |
|
... |
... |
Consider the relations $R$ and $T$ below, and their functional dependencies (on |
4552 |
4594 |
|
|
4553 |
4595 |
| |
| |
4554 |
4596 |
| :---: | |
| :---: | |
4555 |
|
| R(\underline{EventId}, \underline{Email}, Time, Date, Location, Status) | |
|
4556 |
|
| T(\underline{Invno}, Subtotal, Tax, Total, Email, Lname, Fname, Phone) | |
|
|
4597 |
|
| R(E͟v͟e͟n͟t͟I͟d͟, E͟m͟a͟i͟l͟, Time, Date, Location, Status) | |
|
4598 |
|
| T(I͟n͟v͟n͟o͟, Subtotal, Tax, Total, Email, Lname, Fname, Phone) | |
4557 |
4599 |
|
|
4558 |
4600 |
| | | |
| | | |
4559 |
4601 |
---: | :---: | --- | |
---: | :---: | --- | |
|
... |
... |
Problem +.# |
4621 |
4663 |
|
|
4622 |
4664 |
Consider the relation |
Consider the relation |
4623 |
4665 |
|
|
4624 |
|
CONTACT(Phone, Call\_center, Email, Zip, Brand, Website) |
|
|
4666 |
|
CONTACT(Phone, Call\_center, Email, Zip, Brand, Website) |
4625 |
4667 |
|
|
4626 |
|
and the following functional dependencies: |
|
|
4668 |
|
and the following functional dependencies: |
4627 |
4669 |
|
|
4628 |
4670 |
||| |
||| |
4629 |
4671 |
---: | :---: | --- | |
---: | :---: | --- | |
|
... |
... |
Consider the relation |
4632 |
4674 |
\{ Brand\} | → | \{Website\} |
\{ Brand\} | → | \{Website\} |
4633 |
4675 |
\{Phone\} | → | \{Call\_center\} |
\{Phone\} | → | \{Call\_center\} |
4634 |
4676 |
|
|
4635 |
|
<!-- BOGUE --> |
|
4636 |
|
|
|
4637 |
4677 |
Assume that \{Zip, Brand\} is the primary key. |
Assume that \{Zip, Brand\} is the primary key. |
4638 |
4678 |
Normalize this relation to the second normal form, and *then* to the third normal form. |
Normalize this relation to the second normal form, and *then* to the third normal form. |
4639 |
4679 |
Give the relations, their primary keys, and functional dependencies for both steps. |
Give the relations, their primary keys, and functional dependencies for both steps. |
4640 |
4680 |
|
|
|
4681 |
|
--- |
|
4682 |
|
|
4641 |
4683 |
Problem +.#consultation |
Problem +.#consultation |
4642 |
4684 |
~ \ |
~ \ |
4643 |
4685 |
|
|
|
... |
... |
Exercise +.# |
5237 |
5279 |
|
|
5238 |
5280 |
## Solution to Exercises {-} |
## Solution to Exercises {-} |
5239 |
5281 |
|
|
5240 |
|
Solution +.# |
|
|
5282 |
|
Solution +.# |
5241 |
5283 |
~ API + driver |
~ API + driver |
5242 |
5284 |
|
|
5243 |
|
Solution +.# |
|
|
5285 |
|
Solution +.# |
5244 |
5286 |
~ DriverManager.getConnection() |
~ DriverManager.getConnection() |
5245 |
5287 |
|
|
5246 |
|
Solution +.# |
|
|
5288 |
|
Solution +.# |
5247 |
5289 |
~ It checks if there is data to read, and if move the cursor reads it. |
~ It checks if there is data to read, and if move the cursor reads it. |
5248 |
5290 |
It returns a Boolean. |
It returns a Boolean. |
5249 |
5291 |
|
|
5250 |
|
Solution +.# |
|
|
5292 |
|
Solution +.# |
5251 |
5293 |
~ Using |
~ Using |
5252 |
5294 |
|
|
5253 |
5295 |
~~~{.java} |
~~~{.java} |
5254 |
5296 |
.executeQuery(strSelect) |
.executeQuery(strSelect) |
5255 |
5297 |
~~~ |
~~~ |
5256 |
5298 |
|
|
5257 |
|
Solution +.# |
|
|
5299 |
|
Solution +.# |
5258 |
5300 |
~ Before the first line. Using the `next` method. |
~ Before the first line. Using the `next` method. |
5259 |
5301 |
|
|
5260 |
|
Solution +.# |
|
|
5302 |
|
Solution +.# |
5261 |
5303 |
~ `first`, `last`, `next`, `previous`, `relative`, `absolute` methods. |
~ `first`, `last`, `next`, `previous`, `relative`, `absolute` methods. |
5262 |
5304 |
|
|
5263 |
|
Solution +.# |
|
|
5305 |
|
Solution +.# |
5264 |
5306 |
~ 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. |
5265 |
5307 |
|
|
5266 |
|
Solution +.# |
|
|
5308 |
|
Solution +.# |
5267 |
5309 |
~ `ResultSetMetaData` |
~ `ResultSetMetaData` |
5268 |
5310 |
|
|
5269 |
|
Solution +.# |
|
|
5311 |
|
Solution +.# |
5270 |
5312 |
~ 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. |
5271 |
5313 |
|
|
5272 |
|
Solution +.# |
|
|
5314 |
|
Solution +.# |
5273 |
5315 |
~ List errors in program TO DO. |
~ List errors in program TO DO. |
5274 |
5316 |
|
|
5275 |
5317 |
<!-- |
<!-- |
|
... |
... |
Solution +.# |
5287 |
5329 |
%http://tutorials.jenkov.com/jdbc/resultset.html |
%http://tutorials.jenkov.com/jdbc/resultset.html |
5288 |
5330 |
--> |
--> |
5289 |
5331 |
|
|
5290 |
|
Solution +.# |
|
|
5332 |
|
Solution +.# |
5291 |
5333 |
~ Here it is: |
~ Here it is: |
5292 |
5334 |
|
|
5293 |
5335 |
~~~{.java .numberLines} |
~~~{.java .numberLines} |
|
... |
... |
We will compile and execute your first database application, using Java and MySQ |
5395 |
5437 |
Try to execute `FirstProg` without that flag, and see what happens. |
Try to execute `FirstProg` without that flag, and see what happens. |
5396 |
5438 |
|
|
5397 |
5439 |
|
|
5398 |
|
Solution +.# |
|
|
5440 |
|
Solution +.# |
5399 |
5441 |
|
|
5400 |
5442 |
~~~{.bash} |
~~~{.bash} |
5401 |
5443 |
$ java FirstProg |
$ java FirstProg |
|
... |
... |
Can also be used for DBMS fingerprinting. |
5723 |
5765 |
#. Escaping |
#. Escaping |
5724 |
5766 |
#. Be up-to-date, desactivate the options you are not using, read newsfeeds, |
#. Be up-to-date, desactivate the options you are not using, read newsfeeds, |
5725 |
5767 |
|
|
5726 |
|
## To Be Determined |
|
5727 |
|
|
|
5728 |
|
**bogue** Add topics on "Recognize professional responsibilities and make informed judgments in computing practice based on legal and ethical principles." |
|
5729 |
|
|
|
5730 |
5768 |
# Presentation of NoSQL |
# Presentation of NoSQL |
5731 |
5769 |
|
|
5732 |
5770 |
## Resources {-} |
## Resources {-} |
|
... |
... |
Exercise +.# |
6157 |
6195 |
|
|
6158 |
6196 |
## Solution to Exercises {-} |
## Solution to Exercises {-} |
6159 |
6197 |
|
|
6160 |
|
Solution +.# |
|
|
6198 |
|
Solution +.# |
6161 |
6199 |
~ To be written. |
~ To be written. |
6162 |
6200 |
|
|
6163 |
6201 |
|
|