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.
Author |
Topic |
MevaD
Starting Member
32 Posts |
Posted - 2013-09-03 : 21:14:09
|
Sorry if this is in the wrong category...I need to store business and residential accounts in my databse (SQL 2012). I have tried a number of designs but I'm just not sure if I'm missing something. Current design looks like this:Person 1 -- N PersonAccount N -- 1 Account 1 -- N AddressWhere the Account table has a field called AccountType ('B' or 'R')Some of the business rules are as follows:1. A person can belong to many accounts.2. An account can have many persons.3. An account can have many addresses.4. An address can belong to only 1 account.If the above design looks OK, then what is the best query to select all persons that have the same account. And how to select all addresses on an account. ** Can this be done if I only have the personID to start?Thanks.P.S. This is not a homework assignment. |
|
lazerath
Constraint Violating Yak Guru
343 Posts |
Posted - 2013-09-05 : 11:41:15
|
This looks very suspiciously like a homework assignment. What have you tried so far? What are your ideas on how to accomplish this? |
|
|
MevaD
Starting Member
32 Posts |
Posted - 2013-09-05 : 11:53:32
|
No, as I said, this is NOT a homework assignent. I was just asking for input/feedback on my design. Thanks anyway. |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2013-09-06 : 01:35:14
|
Without any DDL it's difficult to judge, let alone write queries for you. How about you start by posting your table definitions and some sample input/output?Also, the account type is irrelevant according to your question but I assume you provided it for a reason. What is it?To start with, I'd guess you want something like thisselect personID from PersonAccount where accountid=?gives you all persons with same accountselect * from address where addressAccountID=?gives you all address from account.but it's impossible to know without more details. |
|
|
|
|
|