Ok, I don’t know exactly how to word this as I’ve never heard or done this but I’m sure someone has. Basically what I am doing is creating a listing for businesses, where fields such as phone numbers, other legal names, SIC codes, etc can have multiple values inserted into a column, for example there can be many phone numbers inserted into the phone number column in the table for that business. How would you achieve this both in mysql and php? Thanks!
Share
This can be done with what’s called a many-to-one[1] relationship.
You have a
companytable, which would hold fields such ascompanyID,name, etc (all the single values (one-to-one) values).Then, you have a
phonestable, which would reference the originalcompanyID, while providing the information in multiple rows. For example:This represents company 1 having two phone numbers, and company 2 having one.
You can easily select those with a MySQL JOIN clause.
1: One company may have multiple phone numbers, but a phone number can only belong to one company.