Ignore:
Timestamp:
01/26/10 15:39:06 (12 years ago)
Author:
timkoma <timkoma@…>
Branches:
master, qt5
Children:
61ff1b8
Parents:
a226ba2
Message:

unique constraints added into sql

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sql/sqlengine.cpp

    ra226ba2 r89ff5f2  
    231231        QSqlQuery query(aDatabase);
    232232
    233         query.exec("CREATE TABLE CONFERENCE ( \
    234             id INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL , \
    235             title VARCHAR UNIQUE NOT NULL , \
    236             subtitle VARCHAR, \
    237             venue VARCHAR, \
    238             city VARCHAR NOT NULL , \
    239             start INTEGER NOT NULL , \
    240             end INTEGER NOT NULL , \
    241             days INTEGER, \
    242             day_change INTEGER, \
    243             timeslot_duration INTEGER)");
    244 
    245         query.exec("CREATE TABLE TRACK ( \
    246             id INTEGER  PRIMARY KEY AUTOINCREMENT  NOT NULL , \
    247             name VARCHAR UNIQUE NOT NULL )");
    248 
    249         query.exec("CREATE TABLE ROOM ( \
    250             id INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL , \
    251             name VARCHAR UNIQUE NOT NULL , \
    252             picture VARCHAR NOT NULL)");
    253 
    254         query.exec("CREATE TABLE PERSON ( \
    255             id INTEGER PRIMARY KEY  NOT NULL , \
    256             name VARCHAR UNIQUE NOT NULL)");
    257 
    258         query.exec("CREATE TABLE EVENT ( \
    259             xid_conference INTEGER  NOT NULL, \
    260             id INTEGER NOT NULL , \
    261             start INTEGER NOT NULL , \
    262             duration INTEGER NOT NULL , \
    263             xid_track INTEGER NOT NULL REFERENCES TRACK(id), \
    264             type VARCHAR, \
    265             language VARCHAR, \
    266             tag VARCHAR,title VARCHAR NOT NULL , \
    267             subtitle VARCHAR, \
    268             abstract VARCHAR, \
    269             description VARCHAR, \
    270             favourite INTEGER DEFAULT 0, \
    271             alarm INTEGER DEFAULT 0, \
    272             PRIMARY KEY (xid_conference,id), \
    273             FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id), \
    274             FOREIGN KEY(xid_track) REFERENCES TRACK(id))");
    275 
    276         query.exec("CREATE TABLE EVENT_PERSON ( \
    277             xid_conference INTEGER NOT NULL , \
    278             xid_event INTEGER NOT NULL , \
    279             xid_person INTEGER NOT NULL, \
    280             FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id), \
    281             FOREIGN KEY(xid_event) REFERENCES EVENT(id), \
    282             FOREIGN KEY(xid_person) REFERENCES PERSON(id))");
    283 
    284         query.exec("CREATE TABLE EVENT_ROOM ( \
    285             xid_conference INTEGER NOT NULL , \
    286             xid_event INTEGER NOT NULL , \
    287             xid_room INTEGER NOT NULL, \
    288             FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id), \
    289             FOREIGN KEY(xid_event) REFERENCES EVENT(id), \
    290             FOREIGN KEY(xid_room) REFERENCES ROOM(id))");
    291 
    292         query.exec("CREATE TABLE LINK ( \
    293             id INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL, \
    294             xid_conference INTEGER NOT NULL, \
    295             xid_event INTEGER NOT NULL, \
    296             name VARCHAR, \
    297             url VARCHAR NOT NULL, \
    298             FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id), \
    299             FOREIGN KEY(xid_event) REFERENCES EVENT(id)");
     233        query.exec("CREATE TABLE CONFERENCE ( "
     234            "id INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL, "
     235            "title VARCHAR UNIQUE NOT NULL, "
     236            "subtitle VARCHAR, "
     237            "venue VARCHAR, "
     238            "city VARCHAR NOT NULL, "
     239            "start INTEGER NOT NULL, "
     240            "end INTEGER NOT NULL, "
     241            "days INTEGER, "
     242            "day_change INTEGER, "
     243            "timeslot_duration INTEGER);");
     244
     245        query.exec("CREATE TABLE TRACK ( "
     246            "id INTEGER  PRIMARY KEY AUTOINCREMENT  NOT NULL, "
     247            "name VARCHAR UNIQUE NOT NULL );");
     248
     249        query.exec("CREATE TABLE ROOM ( "
     250            "id INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL, "
     251            "name VARCHAR UNIQUE NOT NULL, "
     252            "picture VARCHAR NOT NULL);");
     253
     254        query.exec("CREATE TABLE PERSON ( "
     255            "id INTEGER PRIMARY KEY  NOT NULL, "
     256            "name VARCHAR UNIQUE NOT NULL);");
     257
     258        query.exec("CREATE TABLE EVENT ( "
     259            "xid_conference INTEGER  NOT NULL, "
     260            "id INTEGER NOT NULL, "
     261            "start INTEGER NOT NULL, "
     262            "duration INTEGER NOT NULL, "
     263            "xid_track INTEGER NOT NULL REFERENCES TRACK(id), "
     264            "type VARCHAR, "
     265            "language VARCHAR, "
     266            "tag VARCHAR,title VARCHAR NOT NULL, "
     267            "subtitle VARCHAR, "
     268            "abstract VARCHAR, "
     269            "description VARCHAR, "
     270            "favourite INTEGER DEFAULT 0, "
     271            "alarm INTEGER DEFAULT 0, "
     272            "PRIMARY KEY (xid_conference,id), "
     273            "FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id), "
     274            "FOREIGN KEY(xid_track) REFERENCES TRACK(id));");
     275
     276        query.exec("CREATE TABLE EVENT_PERSON ( "
     277            "xid_conference INTEGER NOT NULL, "
     278            "xid_event INTEGER NOT NULL, "
     279            "xid_person INTEGER NOT NULL, "
     280            "UNIQUE ( xid_conference, xid_event, xid_person ) ON CONFLICT IGNORE, "
     281            "FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id), "
     282            "FOREIGN KEY(xid_event) REFERENCES EVENT(id), "
     283            "FOREIGN KEY(xid_person) REFERENCES PERSON(id));");
     284
     285        query.exec("CREATE TABLE EVENT_ROOM ( "
     286            "xid_conference INTEGER NOT NULL, "
     287            "xid_event INTEGER NOT NULL, "
     288            "xid_room INTEGER NOT NULL, "
     289            "UNIQUE ( xid_conference, xid_event, xid_room ) ON CONFLICT IGNORE, "
     290            "FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id), "
     291            "FOREIGN KEY(xid_event) REFERENCES EVENT(id), "
     292            "FOREIGN KEY(xid_room) REFERENCES ROOM(id));");
     293
     294        query.exec("CREATE TABLE LINK ( "
     295            "id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "
     296            "xid_conference INTEGER NOT NULL, "
     297            "xid_event INTEGER NOT NULL, "
     298            "name VARCHAR, "
     299            "url VARCHAR NOT NULL, "
     300            "UNIQUE ( xid_conference, xid_event, url ) ON CONFLICT IGNORE, "
     301            "FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id), "
     302            "FOREIGN KEY(xid_event) REFERENCES EVENT(id));");
    300303    }
    301304    else
Note: See TracChangeset for help on using the changeset viewer.