Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Many To Many with one access point table

Author  Topic 

chacimulch
Starting Member

4 Posts

Posted - 2008-06-03 : 09:07:22
Hello,

First time poster.

I have a database design question. I just read the article on table inheritance but i still do not know if I'm doing this right.

Say you have an organizations table and a persons table like the ones below with a many to many relationship like these three tables:

Organization:
AutoId TaxId Name

Person:
AutoId FirstName LastName

OrganizationsPersons:
AutoId OrgAutoId PersonAutoId


Now the question is that an organization and a person both need to access the address table.

Is it better to have a PersonsAddress table and an OrganizationsAddress table, or is it better to have some sort of AddressAccess table that the persons and the organizations tables both relate to and have some sort of type field in there that specifies Org or Person?

Thanks ahead of time for any help.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-06-03 : 09:10:02
moved from article discusion since that forum is meant to discuss only posted articles.

Welcome to the team chacimulch!

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page

chacimulch
Starting Member

4 Posts

Posted - 2008-06-03 : 09:16:58
I'm not exactly sure what you mean by this? Did I post this in the wrong place?
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-06-03 : 09:17:38
yes article discussion is meant as a comments section for articles posted on the main page.


_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page

chacimulch
Starting Member

4 Posts

Posted - 2008-06-03 : 09:27:21
so what exactly do I need to do to post this so someone will try to help me? Sorry first time user.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-06-03 : 09:44:47
here is a good place. that's why moved it here.

regarding your problem:
i'd probably go with the AddressAccess table and a type field. so if you ever have to add a new type that has address then you just add a new type and not a new table.



_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page

chacimulch
Starting Member

4 Posts

Posted - 2008-06-04 : 11:37:19
FYI for anyone who is reading this. It turns out that using an access table will not work if you enforce the foriegn key constraints to the other tables that will access it. If one of the tables does not contain the value that you are trying to insert, then you cannot insert it. So.. all tables that are linked to the lookup table must contain that value. Not really useful because we want to enforce our relationships.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-06-04 : 11:46:47
well you didn't specify that requirement

i don't know if you read this:
http://www.sqlteam.com/article/implementing-table-inheritance-in-sql-server

but it's exactly what you're dealing with.

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page
   

- Advertisement -