Commit afe270ac authored by Stephane Crozat's avatar Stephane Crozat

Ajout size et ects à la base

parent 9c4e11c1
DROP TABLE IF EXISTS subscribe CASCADE; DROP TABLE IF EXISTS subscribe CASCADE;
DROP TABLE IF EXISTS api; DROP TABLE IF EXISTS api CASCADE;
CREATE TABLE api ( CREATE TABLE api (
code INTEGER PRIMARY KEY, code INTEGER PRIMARY KEY,
...@@ -8,10 +8,14 @@ CREATE TABLE api ( ...@@ -8,10 +8,14 @@ CREATE TABLE api (
semester CHAR(1) NOT NULL, semester CHAR(1) NOT NULL,
dbegin DATE NOT NULL, dbegin DATE NOT NULL,
dend DATE NOT NULL, dend DATE NOT NULL,
size INTEGER,
ects INTEGER NOT NULL,
CHECK (code>0), CHECK (code>0),
CHECK (year>2018 AND year<2100), CHECK (year>2018 AND year<2100),
CHECK (semester IN ('H','E')), CHECK (semester IN ('H','E')),
CHECK (dbegin<=dend), CHECK (dbegin<=dend),
CHECK (size>0),
CHECK (ects>0),
UNIQUE (name,year,semester) UNIQUE (name,year,semester)
); );
...@@ -22,19 +26,25 @@ CREATE TABLE subscribe ( ...@@ -22,19 +26,25 @@ CREATE TABLE subscribe (
PRIMARY KEY (utclogin,api) PRIMARY KEY (utclogin,api)
); );
/** Test dataset **/ /** Test dataset
INSERT INTO api VALUES ( INSERT INTO api VALUES (
1,'Poésie et ingénierie',2019,'H',TO_DATE('20190121','yyyymmdd'),TO_DATE('20190125','yyyymmdd') 1,'Poésie et ingénierie',2019,'H',TO_DATE('20190121','yyyymmdd'),TO_DATE('20190125','yyyymmdd'),24,2
); );
INSERT INTO api VALUES ( INSERT INTO api VALUES (
2,'Cloud big data blockchain IA',2019,'H',TO_DATE('20190125','yyyymmdd'),TO_DATE('20190131','yyyymmdd') 2,'Cloud big data blockchain IA',2019,'H',TO_DATE('20190125','yyyymmdd'),TO_DATE('20190131','yyyymmdd'),12,3
); );
INSERT INTO subscribe VALUES ( INSERT INTO subscribe VALUES (
'crozatst',1,TO_DATE('20181018','YYYYMMDD') 'crozatst',1,TO_DATE('20181018','YYYYMMDD')
); );
**/
CREATE OR REPLACE VIEW vApi AS CREATE OR REPLACE VIEW vApi AS
SELECT ap.code, ap.name, ap.year, ap.semester, TO_CHAR(ap.dbegin,'TMday FMDD TMmonth') AS dbegin, TO_CHAR(ap.dend,'TMday FMDD TMmonth') AS dend SELECT
ap.code,
CASE WHEN ap.code<10 THEN '000'||ap.code WHEN ap.code>=10 THEN '00'||ap.code END AS normcode,
ap.name, ap.year, ap.semester,
TO_CHAR(ap.dbegin,'TMday FMDD TMmonth') AS dbegin, TO_CHAR(ap.dend,'TMday FMDD TMmonth') AS dend,
size, ects
FROM api ap FROM api ap
ORDER BY ap.year, ap.semester, ap.dbegin, ap.dend, ap.code; ORDER BY ap.year, ap.semester, ap.dbegin, ap.dend, ap.code;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment