Jump to content

Serialize data or individual entries suggestion


Roaches

Recommended Posts

I'm trying to figure out the best way to organize data in my mysql database (for a php project). I have a single entry that will have several items for a single field, for example:

 

id | event | dates | etc

 

Using this example, one event might have several dates corresponding to it. My first thought would to just serialize an array with all the dates and place it in the dates field, but as far as I know there isn't a way to order the output of the query by each of those dates. So my other solution would just have another table called something like "event_dates" where it would contain the id of the event and a single date, but I'm worried that might not be the best solution.

 

So my question is what would be the best way to go about this? Would having a separate table containing individual dates create more overhang than having them all be in one field or is there another solution I just haven't been able to think of?

Link to comment
Share on other sites

Would having a separate table containing individual dates create more overhang than having them all be in one field

 

No, it would be considered normalized.

 

 

event

--------------------------------------

id  |  event  |  etc

 

 

event_dates (you can store multiple events with different dates)

--------------------------------------

event_id  |  date(timestamp)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.