Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stephane Crozat
apisub
Commits
bdd55772
Commit
bdd55772
authored
Oct 22, 2018
by
Stephane Crozat
Browse files
add install & sql
parent
d6900121
Changes
3
Show whitespace changes
Inline
Side-by-side
INSTALL
0 → 100644
View file @
bdd55772
DROP USER apisub;
CREATE USER apisub WITH ENCRYPTED PASSWORD 'password';
DROP DATABASE apisub;
CREATE DATABASE apisub;
GRANT ALL PRIVILEGES ON DATABASE apisub TO apisub;
sql/apisub.plantuml
0 → 100644
View file @
bdd55772
/** CTRL+ALT+P to view **/
@startuml
hide circle
class Student {
utclogin : text {key}
mail : mail {key}
surname : text
firstname : text
}
class Api {
code : integer {key}
name : text
year : year
semester : H|E
}
note right of Api : (name,year,semester) key
Student "0..n" - "0..n" Api
(Student, Api) . Subscribe
class Subscribe {
subdate : date
}
@enduml
sql/apisub.sql
0 → 100644
View file @
bdd55772
DROP
TABLE
IF
EXISTS
subscribe
CASCADE
;
DROP
TABLE
IF
EXISTS
api
;
CREATE
TABLE
api
(
code
INTEGER
PRIMARY
KEY
,
name
TEXT
NOT
NULL
,
year
INTEGER
NOT
NULL
,
semester
CHAR
(
1
)
NOT
NULL
,
CHECK
(
code
>
0
),
CHECK
(
year
>
2018
AND
year
<
2100
),
CHECK
(
semester
IN
(
'H'
,
'E'
)),
UNIQUE
(
name
,
year
,
semester
)
);
CREATE
TABLE
subscribe
(
utclogin
TEXT
NOT
NULL
,
api
INTEGER
REFERENCES
api
(
code
),
subdate
DATE
NOT
NULL
,
PRIMARY
KEY
(
utclogin
,
api
)
);
/** Test dataset **/
INSERT
INTO
api
VALUES
(
1
,
'Poésie et ingénierie'
,
2019
,
'H'
);
INSERT
INTO
api
VALUES
(
2
,
'Cloud big data blockchain IA'
,
2019
,
'H'
);
INSERT
INTO
subscribe
VALUES
(
'crozatst'
,
1
,
TO_DATE
(
'20181018'
,
'YYYYMMDD'
)
);
CREATE
VIEW
vSubscrition
AS
SELECT
ap
.
code
,
ap
.
name
,
ap
.
year
,
ap
.
semester
,
su
.
subdate
,
su
.
utclogin
FROM
subscribe
su
JOIN
api
ap
ON
ap
.
code
=
su
.
api
ORDER
BY
ap
.
year
,
ap
.
semester
,
su
.
utclogin
,
ap
.
code
;
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment