?
Solved

What is the best schema ?

Posted on 2007-04-09
2
Medium Priority
?
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

765 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