A
Adrian Jansen
As part of a development, I have to provide a personal contacts table, with
the usual details, name, address, phone etc
I thought about ( hasnt everyone ! ) the problems of providing multiple
addresses, business, personal etc, plus the hassles of handling multiline
department, building, street, suburb, town, etc and realised I could end up
with 20-30 fields in the table, and still not cover all the possibilities.
Then I started thinking about doing it relationally, with three tables:
tblContacts
ContactID PK
Name
etc
tblAddressLines
LineID PK
ContactID FK to tblContacts
AddressTypeID FK to tblAddressType
LineNumber sequence number 1-n for multiline addresses
AddressDetail the actual text
tblAddressType
TypeID PK
Type text, (phone, email, postal, business, etc)
Then tblAddressLines is a 1-M relation with both tblContact and
tblAddressType
so by setting the address type, you can have as many address lines as you
like, sorted by LineNumber to keep the order correct for printing, and also
multiple addresses, without having many fields in the contact table.
Seems like it ought to work, but I am looking for confirmation that its a
sensible way to go, before committing too much work.
--
Regards,
Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
the usual details, name, address, phone etc
I thought about ( hasnt everyone ! ) the problems of providing multiple
addresses, business, personal etc, plus the hassles of handling multiline
department, building, street, suburb, town, etc and realised I could end up
with 20-30 fields in the table, and still not cover all the possibilities.
Then I started thinking about doing it relationally, with three tables:
tblContacts
ContactID PK
Name
etc
tblAddressLines
LineID PK
ContactID FK to tblContacts
AddressTypeID FK to tblAddressType
LineNumber sequence number 1-n for multiline addresses
AddressDetail the actual text
tblAddressType
TypeID PK
Type text, (phone, email, postal, business, etc)
Then tblAddressLines is a 1-M relation with both tblContact and
tblAddressType
so by setting the address type, you can have as many address lines as you
like, sorted by LineNumber to keep the order correct for printing, and also
multiple addresses, without having many fields in the contact table.
Seems like it ought to work, but I am looking for confirmation that its a
sensible way to go, before committing too much work.
--
Regards,
Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control