P
PSI
I have multiple entities ( Company, Employee, Vendors etc ) any of
which can have multiple Address's.
After much googling, and following some much appreciated advice from
respondents to previous posts I have arrived at the following table
structure ( fields scaled down for simplicity ):
tblEntity
=======
EntityID - autonumber, PK
Name - Text
tblCompany
========
ID - autonumber, PK
EntityID - number, FK, 1 t o1 to tblEntity.ID
tblEmployee
========
ID - autonumber, PK
EntityID - number, FK, 1 t o1 to tblEntity.ID
tblAddress
=======
ID - autonumber, PK
EntityID - number, 1 to manyto tblEntityID
Type - number
Address1
City
All relations have IReferential Integrity enabled and Cascade Delete's
enabled.
However I am unable to get this to work. I am trying to enter some
data in Dataview mode for the various tables but always run into an
error because the Entity table requires a record in one of the tables
linked 1 to 1. The only way to add the data is for the EntityID to be
the same in all the 1 to 1 tables which would be logically incorrect.
The second issue is that deleting a record from one of the tables (eg
Company) cascades to the Entity table but doesn't cascade to the
Address table. On the other hand deleteing an entity record does
delete from the Company and Address table. This behavior seems to
indicate that the application needs to always have the EntityID in
order to remove a company/employee etc. rather than the Company.ID
etc. ( This doesn't feel right to me, but if thats the way it works
then no problem)
I'm a real novice with table design so I'm obviously missing something
( ie the big aha ). Any help in setting up this address support
would really be appreciated.
My environment is:
VC++ 6.0, ADO, Jet4,MDA C2.7, Win2K
Thanks
Frank
which can have multiple Address's.
After much googling, and following some much appreciated advice from
respondents to previous posts I have arrived at the following table
structure ( fields scaled down for simplicity ):
tblEntity
=======
EntityID - autonumber, PK
Name - Text
tblCompany
========
ID - autonumber, PK
EntityID - number, FK, 1 t o1 to tblEntity.ID
tblEmployee
========
ID - autonumber, PK
EntityID - number, FK, 1 t o1 to tblEntity.ID
tblAddress
=======
ID - autonumber, PK
EntityID - number, 1 to manyto tblEntityID
Type - number
Address1
City
All relations have IReferential Integrity enabled and Cascade Delete's
enabled.
However I am unable to get this to work. I am trying to enter some
data in Dataview mode for the various tables but always run into an
error because the Entity table requires a record in one of the tables
linked 1 to 1. The only way to add the data is for the EntityID to be
the same in all the 1 to 1 tables which would be logically incorrect.
The second issue is that deleting a record from one of the tables (eg
Company) cascades to the Entity table but doesn't cascade to the
Address table. On the other hand deleteing an entity record does
delete from the Company and Address table. This behavior seems to
indicate that the application needs to always have the EntityID in
order to remove a company/employee etc. rather than the Company.ID
etc. ( This doesn't feel right to me, but if thats the way it works
then no problem)
I'm a real novice with table design so I'm obviously missing something
( ie the big aha ). Any help in setting up this address support
would really be appreciated.
My environment is:
VC++ 6.0, ADO, Jet4,MDA C2.7, Win2K
Thanks
Frank