     
 ALTER TABLE Localisations ADD CONSTRAINT Localisations_Event_Id FOREIGN KEY (eventId)
     REFERENCES Events (id) ON UPDATE CASCADE ON DELETE CASCADE;
+    
+ALTER TABLE Localisations ADD CONSTRAINT Localisations_Location FOREIGN KEY (location)
+    REFERENCES Locations (position) ON UPDATE CASCADE ON DELETE CASCADE;
     
 -- Events
 ALTER TABLE EventParticipants ADD INDEX EventParticipants_Accounts_Events (accountId, eventId);

    id int NOT NULL,
    accountId int NOT NULL,
    accountId2 int NOT NULL,
    groupId int,                                 /* Group id for one to one chat */
    CONSTRAINT Contacts_pk PRIMARY KEY (id)
);

-- Group
CREATE TABLE Groups (
    id int NOT NULL AUTO_INCREMENT,
    name varchar(24) NOT NULL,
    CONSTRAINT Groups_pk PRIMARY KEY (id)
);


ALTER TABLE Messages ADD CONSTRAINT Messages_Group_Id FOREIGN KEY (groupId)
    REFERENCES Groups (id) ON UPDATE CASCADE ON DELETE CASCADE;
    
ALTER TABLE Messages ADD CONSTRAINT Messages_Location FOREIGN KEY (location)
    REFERENCES Locations (position) ON UPDATE CASCADE ON DELETE CASCADE;
    
-- Localisations
ALTER TABLE Localisations ADD CONSTRAINT Localisations_Account_Id FOREIGN KEY (accountId)
