Welcome Guest, Not a member yet? Register   Sign In
MySQL/ Application design
#1

[eluser]Oozooo[/eluser]
Hi all,

I'm currently developing an website that contains a lot of company profiles. I was wondering what the best database setup would be to save the profile information and to keep it as scalable as possible. Not every company has or needs the same options, and the users need to be able to edit their profile.

Is is best partice to have 1 company_profile table with the options, and multiple tables for images/reviews connected to that company? ->

[company_profile]
c_id - c_email - c_opening_time_monday - c_description - etc

[company_images]
c_id - c_filename

[company_review]
c_id - c_review


OR would it be better to have 1 table with:

[company_profile_options]
c_id - c_option_type - c_value

but then i would have to make the c_value type a long_text to have the ability to store the company description :/

Probably a stupid question but i'm just learning this php mysql thingy

Anyone care to help me out ?
#2

[eluser]WanWizard[/eluser]
It all depends how flexible you want to be with the different bits of information.

- if you have a finite set of fields, but some are optional, put it all in a single table
- if you have much variation, store the required fields in a master table, then use a second table for the optional fields

For absolute flexibility, you can use a repository table, which contains all optional fields. You then create a many-to-many between this table and the profile table, and use the relationship table to store the value of each optional field. This approach makes it very easy to dynamically add new fields, I use this approach in an application with user profiles, where users can add extra profile fields themselfs (like address, hobby, name of the cat, ...).




Theme © iAndrew 2016 - Forum software by © MyBB