Solved

What is the best schema ?

Posted on 2007-04-09
2
226 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 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

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…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 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