Forum Moderators: coopster

Message Too Old, No Replies

Multiple flags in mysql/php

Multiple flags in mysql/php

         

Tourex

4:04 pm on Jun 10, 2005 (gmt 0)

10+ Year Member



Please be gentle - I'm new to php

I'm designing a database of supplier. Each supplier may be active in a number of regions. There are ten regions in total.

I first thought I would create a database column for each region - so 10 columns - and set a flag in each, as appropriate to the supplier. This strikes me as inefficient and I'm sure there must be a clever (but simple) way of achieving the same thing.

Any thoughts please - but PLEASE keep it simple and foolproof.

Thanks in anticipation.

Sarah Atkinson

4:28 pm on Jun 10, 2005 (gmt 0)

10+ Year Member



With a relational database of 1 to many i would sugest having 3 tables

table one
2 fields [ID(unique, auto-incrementing),region]
so it would have 10 entires

Table two
2 fields [ID(unique, auto-incrementing),supplier]

Table three
3 fields [ID(unique, auto-incrementing), supplier ID(gotten from table 2), Region ID(goten from table 1)]

The first field in table 3 would be optional but I think it would be safer (And I belive good DB practices) to have an unique ID in each table.

to query these, look in to Joins and aliase

it will make things simpler(sort of), more logical, and cleaner.