Solved

What is the best schema ?

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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 …
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

772 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