List of commits:
Subject Hash Author Date (UTC)
Added comments on procedures from code f3e9c2abac41d5de1c7473867c4f688051dec928 aubert@math.cnrs.fr 2020-12-01 15:46:53
Updated mysql connector 228d86db5498aae94a4d162272fa03a84ae9c532 aubert@math.cnrs.fr 2020-12-01 15:09:46
Updated java beautifier 30f4a79f2d911cd0b6a24c31f968f0d23620965f aubert@math.cnrs.fr 2020-12-01 15:07:50
Worked on procedure example from java 998ea14119a5a3f88efc4b0a126177e85151e43d aubert@math.cnrs.fr 2020-12-01 15:06:47
Brief example of calling a procedure from a program. 1054c9d5c83fb956bdd0b8d884d5ce2c8a9a640e aubert@math.cnrs.fr 2020-11-30 19:00:45
Added solution to second exam d8f62ded96991885a96d561db587988d453a28c8 aubert@math.cnrs.fr 2020-11-05 20:35:50
Quick fix on testing semicolons. 7f48d88d2ed69213d803a7736df3d50330cfecd1 aubert@math.cnrs.fr 2020-11-03 14:14:06
Added simple example to test if semicolon are important in SQL querries. 98097fb11558c08bad630fb3351f99ceb6777de7 aubert@math.cnrs.fr 2020-11-03 14:11:22
Updated spots to https. a8daf1768395aa296bf0dd05783dd53c757d5d19 aubert@math.cnrs.fr 2020-10-05 16:18:44
Adding quiz #2 98e0ae5b8ce766524f60c91adb1040235e1bbf31 aubert@math.cnrs.fr 2020-10-02 19:00:15
Added exam 1 e2f62ae4bf26fcc4b86e8665060ccf3918e7abeb aubert@math.cnrs.fr 2020-09-24 12:51:36
worked on solution to first exam. b13ad99dd895f124df1b642fd990071fc09db294 aubert@math.cnrs.fr 2020-09-23 17:44:01
Added solution to first problem. 0948cee47ed78dc115fd69c7bcf96a312dd3162f aubert@math.cnrs.fr 2020-09-18 21:43:00
Added solution to problem 2 of Exam #1. 7ad20b3c0025a4de3fa00729de570c6fe9176773 aubert@math.cnrs.fr 2020-09-18 21:34:19
Added solution to project 1. de427d78745593ab53dc70e7129b67fee1d4489c aubert@math.cnrs.fr 2020-09-10 19:04:45
Added example for MAX and NULL values. b82a496a5ffbcecaf2c5851f18d1b08ce8732623 aubert@math.cnrs.fr 2020-09-10 13:14:13
Changed SQL code formatting. 6c3cad5a2545f46ab113f7df7a83457857d82ed8 aubert@math.cnrs.fr 2020-09-09 17:04:55
Cleaned code. 5bdb4faed3a83b81257734f1e1aced2890783f04 aubert@math.cnrs.fr 2020-09-03 21:35:41
Added the first project. 564a02887933f2395bc40d7d8a10833f657659fd aubert@math.cnrs.fr 2020-08-28 22:34:08
Week 2 edits, added quiz #1, couple of fixes, replaced single quote with double quotes. 3c9942731678900122088356db3a2cbabd99b9be aubert@math.cnrs.fr 2020-08-27 19:00:13
Commit f3e9c2abac41d5de1c7473867c4f688051dec928 - Added comments on procedures from code
Author: aubert@math.cnrs.fr
Author date (UTC): 2020-12-01 15:46
Committer name: aubert@math.cnrs.fr
Committer date (UTC): 2020-12-01 15:46
Parent(s): 228d86db5498aae94a4d162272fa03a84ae9c532
Signer:
Signing key:
Signing status: N
Tree: 2eb619eb1976ef4803be26178ec1f2080b4b0b4f
File Lines added Lines deleted
install/INSTALL.md 2 0
notes/Makefile 1 0
notes/code/java/CallProcedure.java 2 2
notes/lectures_notes.md 21 0
File install/INSTALL.md changed (mode: 100644) (index 18ea7f0..c2dbc3c)
... ... To compile [those notes](../README.html), you need
21 21 - librsvg2-bin, - librsvg2-bin,
22 22 - font-linuxlibertine - font-linuxlibertine
23 23
24 **Warning: as of now (Nov. 2020), you actually need [pandoc 2.9.2.1](https://github.com/jgm/pandoc/releases/tag/2.9.2.1),
25
24 26 Then, clone the repository at <https://rocketgit.com/user/caubert/CSCI_3410>, and refer to [the example file](../notes/example.html) for a gentle test and guide on the syntax and tool of this document. Then, clone the repository at <https://rocketgit.com/user/caubert/CSCI_3410>, and refer to [the example file](../notes/example.html) for a gentle test and guide on the syntax and tool of this document.
25 27 Change the current folder to `notes`, and execute `make example`. Change the current folder to `notes`, and execute `make example`.
26 28 You can have a look at `notes/Makefile` to understand what is happening in the `example` rule. You can have a look at `notes/Makefile` to understand what is happening in the `example` rule.
File notes/Makefile changed (mode: 100644) (index ffc3395..3b72f7d)
... ... MAKEFLAGS:= -j
15 15 # Maximize parallel execution whenever possible # Maximize parallel execution whenever possible
16 16 OPTIONSPANDOC:= --toc --filter pandoc-numbering --citeproc --filter pandoc-include-code --top-level-division=chapter -M date="$$(LANG=en_us_88591 date '+%B %e, %Y (%r)')" --lua-filter filters/default-code-class.lua -M default-code-class=sqlmysql OPTIONSPANDOC:= --toc --filter pandoc-numbering --citeproc --filter pandoc-include-code --top-level-division=chapter -M date="$$(LANG=en_us_88591 date '+%B %e, %Y (%r)')" --lua-filter filters/default-code-class.lua -M default-code-class=sqlmysql
17 17 # Options common to all invokations of pandoc. Cf https://pandoc.org/MANUAL.html to understand them. # Options common to all invokations of pandoc. Cf https://pandoc.org/MANUAL.html to understand them.
18 # -citeproc used to be --filter pandoc-citeproc
18 19 OPTIONSPANDOCODT:= $(OPTIONSPANDOC) --default-image-extension=svg OPTIONSPANDOCODT:= $(OPTIONSPANDOC) --default-image-extension=svg
19 20 OPTIONSPANDOCHTML:= $(OPTIONSPANDOC) --css=style/style.css -B style/foldable_toc.html -B style/anchors_header.html -A style/anchors_footer.html --section-divs --toc-depth=2 --self-contained --default-image-extension=svg OPTIONSPANDOCHTML:= $(OPTIONSPANDOC) --css=style/style.css -B style/foldable_toc.html -B style/anchors_header.html -A style/anchors_footer.html --section-divs --toc-depth=2 --self-contained --default-image-extension=svg
20 21 OPTIONSPANDOCPDF:= $(OPTIONSPANDOC) --pdf-engine=xelatex --pdf-engine-opt=-shell-escape -V links-as-notes --default-image-extension=pdf OPTIONSPANDOCPDF:= $(OPTIONSPANDOC) --pdf-engine=xelatex --pdf-engine-opt=-shell-escape -V links-as-notes --default-image-extension=pdf
File notes/code/java/CallProcedure.java changed (mode: 100644) (index 9526ec0..5dcc678)
... ... public class CallProcedure {
18 18 + "CREATE SCHEMA HW_CALL_TEST;" + "CREATE SCHEMA HW_CALL_TEST;"
19 19 + "USE HW_CALL_TEST;"); + "USE HW_CALL_TEST;");
20 20
21 stmt.execute("CREATE TABLE Test1 (" + "A INT PRIMARY KEY);");
21 stmt.execute("CREATE TABLE Test1 (A INT PRIMARY KEY);");
22 22
23 23 stmt.execute("INSERT INTO Test1 VALUES (1), (2), (3);"); stmt.execute("INSERT INTO Test1 VALUES (1), (2), (3);");
24 24 // To create a procedure, we don't need to change the delimiter! // To create a procedure, we don't need to change the delimiter!
25 25 // Cf. https://stackoverflow.com/a/5314879/ for instance. // Cf. https://stackoverflow.com/a/5314879/ for instance.
26 26 stmt.execute( stmt.execute(
27 " CREATE PROCEDURE List () " + " BEGIN " + " SELECT * " + " FROM Test1; " + " END; ");
27 " CREATE PROCEDURE List () BEGIN SELECT * FROM Test1; END; ");
28 28 // We create a CallabaleStatement object // We create a CallabaleStatement object
29 29 // https://docs.oracle.com/javase/7/docs/api/java/sql/CallableStatement.html // https://docs.oracle.com/javase/7/docs/api/java/sql/CallableStatement.html
30 30 // that extends PreparedStatements and allow to call procedures. // that extends PreparedStatements and allow to call procedures.
File notes/lectures_notes.md changed (mode: 100644) (index 0087285..219e9c2)
... ... You can find below a simple example of "scrollable" `ResultSet`:
8434 8434
8435 8435 You can also have a look at the end of `code/java/AdvancedProg.java`, which creates a second `Statement` object is created and used. You can also have a look at the end of `code/java/AdvancedProg.java`, which creates a second `Statement` object is created and used.
8436 8436
8437 ## A Delicate Balance
8438
8439 Forgetting about the technical difficulties for a minute, there is always the issue of finding the right balance between what the application, and what the database, should do.
8440 Any control structure should be dealt with by the application, and queries (such as select project joins) should be done by the DBMS, but the line may be a bit blurry at times.
8441 For instance, should the schema being created from the application? Probably yes if this is an operation that needs to be performed repeatedly (to "reboot" your schema), or if you want your application to be as portable as possible.
8442 Otherwise, it may make little sense.
8443
8444 Another question is: if a task need to be performed repeatedly, should you create a method in the application, or a procedure in the DBMS?
8445 Once again, it will depend: if you need to read information from the user or if using control flow is crucial to your task, then a method seems more adequate.
8446 But if the task is essentially a series of queries, then creating a procedure may have benefits:
8447
8448 - A procedure will be accessible from any application, and from the command-line as well,
8449 - A procedure will be pre-parsed and optimized on the database side,
8450 - A procedure can serve as a "bridge" between a schema that may evolve and an application that requires resilience from the DBMS. Typically, if two attributes are swapped in the schema, it may not impact the order in which the arguments are passed to the procedure, which ultimately save from having to edit the application.
8451
8452 As an example of how to technically declare and use a procedure from an application, refer to the following code:
8453
8454 ```{.java .numberLines include=code/java/CallProcedure.java}
8455 ```
8456
8457
8437 8458 ## Exercises {-} ## Exercises {-}
8438 8459
8439 8460 Exercise +.# Exercise +.#
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