Forum Moderators: open

Message Too Old, No Replies

Advice on db layout and tables

having a tough time deciding on a system

         

proper_bo

8:52 pm on Nov 13, 2005 (gmt 0)

10+ Year Member



Here is the problem.

I am adding advanced business listings to a site that currently offers basic listings for free.
The basic business listings are all held in one table with columns such as business type, address, phone number, description.

The advanced listings will be different depending on the business type. For example pubs will get tv sport, children policy, beer selection, ambience etc, where as restaurants will get menu, opening hours, special offers etc. Some options will cross over but many will be different.

My idea is this:
one table lists advanced types and an id for them (pub, restaurant, takeaway etc):

id - types
1..- pub
2..- restaurant
3..- takeaway

one table maps advanced types to options:

id - type - description
1 .- 1 . . - beer selection
2 .- 1 . . - children policy
3 .- 2 . . - menu
4 .- 2 . . - opening hours
5 .- 2 . . - external image

one table holds the actual info or image as a blob and maps to the options

id - advanced_type - bus_id - text . . . . .- image
1 .- 4 . . . . . . . . . - 117 . . - 9am-3pm . .- X
2 .- 2 . . . . . . . . . - 117 . . - out by 6pm - X
1 .- 5 . . . . . . . . . - 117 . . - X . . . . . . .- image data

so there you go. not the simplest of layouts as it takes several calls to get all the info for a business with advanced details.

Any ideas on a better layout.
Any questions? Ask away.

Thank you all.

arran

3:50 pm on Nov 14, 2005 (gmt 0)

10+ Year Member



several calls to get all the info for a business with advanced details

How so? Would the following statement not pull back the information you require?

select business.type, advanced.option, info.text, info.image from business, advanced, info where business.id = option.type and option.id = info.advanced_type and info.bus_id = business.id and business.id = <the_id_you_require>

arran.

proper_bo

4:00 pm on Nov 14, 2005 (gmt 0)

10+ Year Member



brilliant. hadn't thought of calls like that.

so the general layout of tables looks ok?
can you think of any improvements?