List of commits:
Subject Hash Author Date (UTC)
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
Initial commit, draft of lecture notes. 200d2739bca881d60c7c9381b16f5a4d6384ff29 aubert@math.cnrs.fr 2018-05-16 15:35:36
Commit d4230fce5210d1d8905a42d11634e49e82217541 - Les exercises compilent :-)
Author: aubert@math.cnrs.fr
Author date (UTC): 2018-05-19 19:09
Committer name: aubert@math.cnrs.fr
Committer date (UTC): 2018-05-19 19:09
Parent(s): 40dd86cdc624209a2282d4437921f46325c2cfa1
Signer:
Signing key:
Signing status: N
Tree: 9adea9aa971556e17a881e044ac35bf11683213a
File Lines added Lines deleted
exercises/sum.md 39 59
File exercises/sum.md changed (mode: 100644) (index 58bf839..503c092)
... ... A friend of yours want you to review and improve the code for a role-playing gam
2536 2536 The original idea was that each character should have a name, a class (e.g., Bard, Assassin, Druid), a certain amount of experience, a level, one or more weapons (providing bonuses) and can complete quests. The original idea was that each character should have a name, a class (e.g., Bard, Assassin, Druid), a certain amount of experience, a level, one or more weapons (providing bonuses) and can complete quests.
2537 2537 A quest have a name, and rewards the characters that completed it with a certain amount of experience, and sometimes (but rarely) with a special item. A quest have a name, and rewards the characters that completed it with a certain amount of experience, and sometimes (but rarely) with a special item.
2538 2538
2539 Your friend came up with the code presented in \autoref{lst:RPG}, page~\pageref{lst:RPG}, but there are several problems:
2539 Your friend came up with the following code:
2540 2540
2541 \begin{itemize}
2542 \item As of now, a character can have only one weapon.
2541 ```sqlmysql
2542 CREATE TABLE CHARACTER(
2543 Name VARCHAR(30) PRIMARY KEY,
2544 Class VARCHAR(30),
2545 XP INT,
2546 LVL INT,
2547 Weapon_Name VARCHAR(30),
2548 Weapon_Bonus INT,
2549 Quest_Completed VARCHAR(30)
2550 );
2551
2552 CREATE TABLE QUEST(
2553 Id VARCHAR(20) PRIMARY KEY,
2554 Completed_By VARCHAR(30),
2555 XP_Gained INT,
2556 Special_Item VARCHAR(20),
2557 FOREIGN KEY (Completed_By) REFERENCES CHARACTER(Name)
2558 );
2559
2560 ALTER TABLE CHARACTER ADD FOREIGN KEY (Quest_Completed) REFERENCES QUEST(Id);
2561 ```
2562
2563 But there are several problems.
2564
2565 - As of now, a character can have only one weapon.
2543 2566 All the attempts to "hack" the `CHARACTER` table to add an arbitrary number of weapons ended up creating horrible messes. All the attempts to "hack" the `CHARACTER` table to add an arbitrary number of weapons ended up creating horrible messes.
2544 \item Every time a character completes a quest, a copy of the quest must be created.
2567 - Every time a character completes a quest, a copy of the quest must be created.
2545 2568 Your friend is not so sure why, but nothing else works. Your friend is not so sure why, but nothing else works.
2546 2569 Also it seems that a character can complete only one quest, but your friend is not so sure about that. Also it seems that a character can complete only one quest, but your friend is not so sure about that.
2547 \item It would be nice to be able to store features that are tied to the class, and not to the character, like the bonus they provide and the associated element (e.g., all bards use fire, all assassins use wind, etc.).
2570 - It would be nice to be able to store features that are tied to the class, and not to the character, like the bonus they provide and the associated element (e.g., all bards use fire, all assassins use wind, etc.).
2548 2571 But you friend simply can't figure out how to do that. But you friend simply can't figure out how to do that.
2549 \end{itemize}
2550 2572
2551 2573 Can you provide a \emph{relational database schema} (no need to write the `SQL` code, but remember to indicate the primary and foreign keys) that would solve all of your friend's troubles? Can you provide a \emph{relational database schema} (no need to write the `SQL` code, but remember to indicate the primary and foreign keys) that would solve all of your friend's troubles?
2552 2574
 
... ... Map that E.-R. diagram to a relational database schema.
2576 2598
2577 2599
2578 2600
2579 \begin{figure}
2580 %\begin{listing}
2581
2582 ```sqlmysql
2601 ~~~{.sqlmysql caption="A `SQL` Code for a Role-Playing Game"}
2583 2602 CREATE TABLE CHARACTER( CREATE TABLE CHARACTER(
2584 2603 Name VARCHAR(30) PRIMARY KEY, Name VARCHAR(30) PRIMARY KEY,
2585 2604 Class VARCHAR(30), Class VARCHAR(30),
 
... ... FOREIGN KEY (Completed_By) REFERENCES CHARACTER(Name)
2600 2619
2601 2620 ALTER TABLE CHARACTER ADD FOREIGN KEY (Quest_Completed) REFERENCES QUEST(Id); ALTER TABLE CHARACTER ADD FOREIGN KEY (Quest_Completed) REFERENCES QUEST(Id);
2602 2621 ``` ```
2622 <!-- Add a label? #lst:RPG -->
2603 2623
2604 2624
2605 %\end{listing}
2606 \caption{A `SQL` Code for a Role-Playing Game}
2607 \label{lst:RPG}
2608 \end{figure}
2609
2610 2625 \begin{figure} \begin{figure}
2611 2626 \begin{tikzpicture}[node distance=8em] \begin{tikzpicture}[node distance=8em]
2612 2627 \node[entity] (COUNTRY) {COUNTRY}; \node[entity] (COUNTRY) {COUNTRY};
 
... ... You can indicate your steps, justify your reasoning, and indicate the foreign ke
2702 2717
2703 2718
2704 2719 Problem +.# Problem +.#
2705 Consider the set of requirements in Figure~\ref{fig:reqUNIV}, p.~\pageref{fig:reqUNIV}.
2720 Consider the following requirements for a UNIVERSITY database, used to keep track of students' transcripts.
2721
2722 #. The university keeps track of each student's name, student number, class (freshman, sophomore, …, graduate), major department, minor department (if any), and degree program (B.A., B.S., …, Ph.D.).
2723 Student number has unique values for each student.
2724 #. Each department is described by a name and has a (unique) department code.
2725 #. Each course has a course name, a course number, credit hours, and is offered by at least one department. The value of course number is unique for each course. A course has at least one section.
2726 #. Each section of a course has an instructor, a semester, a year, and a section number.
2727 The section number distinguishes different sections of the same course that are taught during the same semester/year; its values are 1, 2, 3, …, up to the number of sections taught during each semester. Students can enroll in sections and receive a letter grade, and grade point (0, 1, 2, 3, 4 for F, D, C, B, A, respectively).
2728
2706 2729 Draw an E.-R. diagram for that schema. Draw an E.-R. diagram for that schema.
2707 2730 Specify key attributes of each entity type and structural constraints on each relationship type. Specify key attributes of each entity type and structural constraints on each relationship type.
2708 2731 Note any unspecified requirements, and make appropriate assumptions to make the specification complete. Note any unspecified requirements, and make appropriate assumptions to make the specification complete.
 
... ... Don't forget to indicate primary and foreign keys.
2781 2804 \label{fig:RelMod} \label{fig:RelMod}
2782 2805 \end{figure} \end{figure}
2783 2806
2784 \begin{figure}
2785 Consider the following requirements for a UNIVERSITY database, used to keep track of students' transcripts.
2786
2787 #. The university keeps track of each student's name, student number, class (freshman, sophomore, …, graduate), major department, minor department (if any), and degree program (B.A., B.S., …, Ph.D.).
2788 Student number has unique values for each student.
2789 #. Each department is described by a name and has a (unique) department code.
2790 #. Each course has a course name, a course number, credit hours, and is offered by at least one department. The value of course number is unique for each course. A course has at least one section.
2791 #. Each section of a course has an instructor, a semester, a year, and a section number.
2792 The section number distinguishes different sections of the same course that are taught during the same semester/year; its values are 1, 2, 3, …, up to the number of sections taught during each semester. Students can enroll in sections and receive a letter grade, and grade point (0, 1, 2, 3, 4 for F, D, C, B, A, respectively).
2793
2794 \caption{Requirements for a UNIVERSITY database}
2795 \label{fig:reqUNIV}
2796 \end{figure}
2797 2807
2798 2808 \begin{figure} \begin{figure}
2799 2809 \begin{tikzpicture}[scale = 0.8] \begin{tikzpicture}[scale = 0.8]
 
... ... Map that E.-R. diagram to a relational database schema.
2956 2966
2957 2967
2958 2968
2959 \begin{figure}
2960 %\begin{listing}
2961 ```sqlmysql
2962 CREATE TABLE CHARACTER(
2963 Name VARCHAR(30) PRIMARY KEY,
2964 Class VARCHAR(30),
2965 XP INT,
2966 LVL INT,
2967 Weapon_Name VARCHAR(30),
2968 Weapon_Bonus INT,
2969 Quest_Completed VARCHAR(30)
2970 );
2971
2972 CREATE TABLE QUEST(
2973 Id VARCHAR(20) PRIMARY KEY,
2974 Completed_By VARCHAR(30),
2975 XP_Gained INT,
2976 Special_Item VARCHAR(20),
2977 FOREIGN KEY (Completed_By) REFERENCES CHARACTER(Name)
2978 );
2979
2980 ALTER TABLE CHARACTER ADD FOREIGN KEY (Quest_Completed) REFERENCES QUEST(Id);
2981 ```
2982
2983
2984 %\end{listing}
2985 \caption{A `SQL` Code for a Role-Playing Game}
2986 \label{lst:RPG}
2987 \end{figure}
2988
2989 2969 \begin{figure} \begin{figure}
2990 2970 \begin{tikzpicture}[node distance=8em] \begin{tikzpicture}[node distance=8em]
2991 2971 \node[entity] (COUNTRY) {COUNTRY}; \node[entity] (COUNTRY) {COUNTRY};
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