2

I'm writing up a job recruitment site for ex-military personnel in PHP/MySQL and I'm at a stage where I'm not sure which direction to take

I have a "candidate" table with all the usual firstname, surname etc and a unique candidate_id, and an address table linked by the unique candidate_id

The client has asked for more data to be captured, as in driving licence type, religion, SIA Level (Security Industry Authority), languages spoken etc

My question is, with all this different data, is it worth setting up dedicated tables for each? So for example having a driving licence table, with all the different types of driving licence, each with a unique id, then linked to the candidate table with a driving_licence_id cell?

Or should I just serialize all the extra data as text and put it in one cell in the candidate table?

2
  • 1
    If you are willing to have a major headache of modifying that data - go on and serialize it (my personal experience). At the moment I can imagine just one valid use case for this - those data will be used mostly by javascript, so you just serialize into JSON and be happy. Commented Jan 17, 2012 at 13:07
  • 1
    "Not going to be used for querying", my foot. Commented Jan 18, 2012 at 11:09

4 Answers 4

5

My question is, with all this different data, is it worth setting up dedicated tables for each?

Yes. That is what databases are for.

Sign up to request clarification or add additional context in comments.

2 Comments

Would there not be a decrease in performance due to all the joins required?
performance has nothing to do with this question at all. It is absolutely irrelevant matter.
4

Dedicated tables versus serialized data is called Database Normalization and Denormalization, respectively. In some cases both options are acceptable, but you should really make an educated choice, by reading up on the subject (for example here on about.com).

Personally I usually prefer working with normalized databases, as they are much easier to query for complex aggregated data. Besides, I feel they are easier to maintain as well, since you usually don't have to refactor when adding new fields and tables.

Finally, unless you have a lot of tables, you are unlikely to run into performance problems due to the number of one-to-one joins (the kind of data that's easy to denormalize).

4 Comments

The extra data is not going to be used for querying, so I think serializing is the way forward. Thanks!
bulk storage has nothing in common with Denormalization
@Andy this assumption (not going to be used for querying) is going to be grave mistake. The data demands to be queried. This is job recruitment site, dude. An employer may (and will) wish to see candidates with certain abilities, like certain SIA level etc.
Like I said in my answer, I prefer normalized databases, they're simply more future-proof and apart from very large scale examples the performance usually won't be a problem.
4

It depends on whether you wish to query this data. If so keep the data normalised (eg in it's own logically separated table), otherwise, if it's just meta data to be pulled along for the ride, whatever is simplest seems reasonable.

Neither approach necessarily precludes the other in the future, simple migration scripts can be created to move the data from one format to the other. I would suggest doing what is simplest to enable you to work on other features of the site soonest.

Comments

2

You must Always go for normalization, believe me. I made the mistake of going through the easy way and store data improperly (not only serialized, implode strings of multidimensional arrays ), then when the time came i had to re design the whole thing and it was a lot of time wasted.

I will never go by the wrong way again, clients can say "no" today, but "report (queries)" tomorrow.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.