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)


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.

  • Google for intersection table and many-to-many relationship. – Joel Brown Jul 1 '15 at 19:59

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:

  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. 

CREATE TABLE Event_Location 
  Location_ID INTEGER PRIMARY KEY,  -- FK in Event table
  Location_Description VARCHAR(50)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.