Solved

What is the best schema ?

Posted on 2007-04-09
2
219 Views
Last Modified: 2010-03-19
Hi Experts,

My tables look like this:
Users (UserId,...)
Companies (CompanyId,...)
Addresses (AddressId,...)

What is the best schema ?
Schema1:
Users_Addresses (UserAddressId, UserId, AddressId)
Companies_Addresses (CompanyAddressId, CompanyId, AddressId)
I can link UserAddressId or CompanyAddressId to another table.

Schema 2:
Group_Addresses (GroupId, UserId, CompanyId, AddressId) with CHECK constraint
CHECK(UserId IS NOT NULL AND CompanyId IS NULL  OR UserId IS NULL AND CompanyId IS NOT NULL)
I can link GroupId to another table.

Or any other schema ?

In any case,  I need to link the user address or the company address to another table.

Thanks in advance for your help.
0
Comment
Question by:noulouk
2 Comments
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 500 total points
ID: 18876759
do users belong to companies?

have you just considered and addressuage table?

addressusage
usagetype, addressid, addressuser -- either a userid or a companyid

?
0
 
LVL 9

Author Comment

by:noulouk
ID: 18876915
Yes Users belong to Companies.

What do you mean by address usage ?
Is it something like this:
AddressUsage (AddressUsageId, UsageType, AddressId, UserOrCompanyId)
and I create relationships between UserId - UserOrCompanyId and CompanyId - UserOrCompanyId.

If so, I didn't know this was possible.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now