There's a many:1 relationship users:accounts. Salesrep:account is a
subset of this relationship. The 1:1 nature of this is a restraint I'd
enforce outside the DB proper.
That is, I would check to see if there's a user for the account where
the usertype is salesrep before inserting another one.
Alternately, there's no reason (that I know of) that you can't have both
relationships. Users are related to accounts which are related to their
"official" sales rep. The main problem I see with this is it could get
a little confusing.
Someone with a deeper knowledge of SQL (or who is smarter than me) might
have a better idea.
--Ben
Jim McAtee wrote:
> I've got a db that includes the following tables:
>
> Accounts
> ------------------
> AccountID PK
> Name
> AccountRepID FK
>
>
> Users
> ------------------
> UserID PK
> Name
> Username
> Password
> AccountID FK
> UserType
>
>
> The Users table will be used for logins to the system. In the Users table
> will be
>
> SysAdmins system administrators
> AccountReps account sales representatives
> AccountOwners Account owners
> AccountUsers Acount editors
>
> I have a 1:1 relationship from Accounts to sales reps in the Users. But
> I'd also like a many:1 relationship from Users who either own accounts or
> are editors of those accounts. I can't have both relationships.
>
> How best to approach this?
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

