Table structure for events

database-design

Got a bit stuck, need a hand.

I need to store events at the database, and events may happen at

  • different location
  • multiple locations
  • at the same time

so these are my tables

CREATE TABLE location(id, name, address)

and

CREATE TABLE event (id, name, date)

Where should I add the location in this design?

The simple (id, name, date, location_id REFERENCES location) won't do, because one event may happen at different locations and I don't want to store 2+ rows of the same event since event is unique.

Best Answer

Hmm... I'm a bit confused. By definition, if two events happen at different places, then they're different events.

My advice in this scenario is to tave 3 tables as follows:

CREATE TABLE Event
(
  Event_ID INTEGER, 
  Event_Description INTEGER,  -- FK   
  Event_Location INTEGER,  -- FK
  Event_Date DATETIME
);

And then two other "parent" tables

CREATE TABLE Event_Description
(
  Description_ID INTEGER PRIMARY KEY, -- FK in Event table. 
  ED_DESCRIPTION VARCHAR(50));
);


CREATE TABLE Event_Location 
(
  Location_ID INTEGER PRIMARY KEY,  -- FK in Event table
  Location_Description VARCHAR(50)
);