开发者

Can't decide database structure. Which one should i go for?

I'm developing small application for a company. What they wa开发者_如何学运维nt me to do is some kind of event website which they can add participants for each event. My question is should I have one table for all the participants for all events or should I create a table for each event and store participants inside it ?

Sorry about my English if there are any grammar errors.


You should have 3 tables:

One with participants (participant_id, name, address...)

One with events (event_id, date, place...)

and one with participants to the events (id, participant_id, event_id)


Personally, I would use three tables. The first stores the list of events, the second stores the list of participants, and the third contains the relationship between events and participants (stores event_id and participant_id combinations).

That allows you to keep a list of participant details that's separate from any given event, so they can be invited to/added as participants of future events from a pre-populated list, rather than requiring the same details to be added repeatedly.


Tables for events, participants and their relations. Read about data normalization.


The following tables should help you map the requirement:

Events - to hold all the Event specific Information Users - to hold all the Users in the website (remember, a user can participate in more than 1 event) Participants - this holds the relationship (many to many) for the users who participate in the Events

So sample columns:

  • Events - event_name, event_description, event_date
  • Users - first_name, last_name, email
  • Participants - event_id(fk : Events.id), user_id(fk: Users.id)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜