source: src/create_tables.sql @ f657e9c

qt5
Last change on this file since f657e9c was f657e9c, checked in by Philipp Spitzer <philipp@…>, 11 years ago

Changed UNIQUE statements in the database table definition so that they make sense for multiple conferences and do no not prevent successful imports.

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[cfe9990]1BEGIN TRANSACTION;
2CREATE TABLE CONFERENCE ( id INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL
3    , title VARCHAR UNIQUE NOT NULL
4    , subtitle VARCHAR
5    , venue VARCHAR
6    , city VARCHAR NOT NULL
7    , start INTEGER NOT NULL
8    , end INTEGER NOT NULL
9    , days INTEGER
10    , day_change INTEGER
11    , timeslot_duration INTEGER
12    , active INTEGER DEFAULT 0
[f657e9c]13    , url VARCHAR
[cfe9990]14    , map VARCHAR);
15
16CREATE TABLE TRACK ( id INTEGER  PRIMARY KEY AUTOINCREMENT  NOT NULL
17    , xid_conference INTEGER -- NOT NULL
[f657e9c]18    , name VARCHAR NOT NULL
19    , UNIQUE (xid_conference, name));
[cfe9990]20
21CREATE TABLE ROOM ( id INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL
22    , xid_conference INTEGER -- NOT NULL
[f657e9c]23    , name VARCHAR NOT NULL
24    , picture VARCHAR NOT NULL
25    , UNIQUE (xid_conference, name));
[cfe9990]26
27CREATE TABLE PERSON ( id INTEGER PRIMARY KEY  NOT NULL
28    , xid_conference INTEGER -- NOT NULL
[f657e9c]29    , name VARCHAR NOT NULL
30    , UNIQUE (xid_conference, name));
[cfe9990]31
32CREATE TABLE EVENT ( xid_conference INTEGER  NOT NULL
33    , id INTEGER NOT NULL
34    , start INTEGER NOT NULL
35    , duration INTEGER NOT NULL
36    , xid_track INTEGER NOT NULL REFERENCES TRACK(id)
37    , type VARCHAR
38    , language VARCHAR
39    , tag VARCHAR
40    , title VARCHAR NOT NULL
41    , subtitle VARCHAR
42    , abstract VARCHAR
43    , description VARCHAR
44    , favourite INTEGER DEFAULT 0
45    , alarm INTEGER DEFAULT 0
46    , PRIMARY KEY (xid_conference ,id)
47    , FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id)
48    , FOREIGN KEY(xid_track) REFERENCES TRACK(id));
49
50CREATE TABLE EVENT_PERSON ( xid_conference INTEGER NOT NULL
51    , xid_event INTEGER NOT NULL
52    , xid_person INTEGER NOT NULL
53    , UNIQUE ( xid_conference , xid_event , xid_person ) ON CONFLICT REPLACE
54    , FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id)
55    , FOREIGN KEY(xid_conference, xid_event) REFERENCES EVENT(xid_conference, id)
56    , FOREIGN KEY(xid_person) REFERENCES PERSON(id));
57
58
59CREATE TABLE EVENT_ROOM ( xid_conference INTEGER NOT NULL
60    , xid_event INTEGER NOT NULL
61    , xid_room INTEGER NOT NULL
62    , UNIQUE ( xid_conference , xid_event , xid_room ) ON CONFLICT REPLACE
63    , FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id)
64    , FOREIGN KEY(xid_conference, xid_event) REFERENCES EVENT(xid_conference, id)
65    , FOREIGN KEY(xid_room) REFERENCES ROOM(id));
66
67CREATE TABLE LINK ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
68    , xid_conference INTEGER NOT NULL
69    , xid_event INTEGER NOT NULL
70    , name VARCHAR
71    , url VARCHAR NOT NULL
72    , UNIQUE ( xid_conference , xid_event , url ) ON CONFLICT REPLACE
73    , FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id)
74    , FOREIGN KEY(xid_conference, xid_event) REFERENCES EVENT(xid_conference, id));
75COMMIT;
Note: See TracBrowser for help on using the repository browser.