SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Junction table problem
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

abbyG
Starting Member

1 Posts

Posted - 10/04/2012 :  16:17:59  Show Profile  Reply with Quote
Greetings,
I have a design problem that I am having trouble with.
I'll preface with the fact that I am not real experienced with SQL design.
My problem is that I have 2 tables with data (Operations and Objects) that are joined in a many-to-many relationship with a bridge or junction table (Permissions). Now I want to assign roles to permissions by creating a many-to-many relationship between the Roles table and the Permissions table, which is itself a junction table. To accomplish the many-to-many relationship between these, I have a RolesToPermissions junction table. The problem arises when I try to make the 1-to-many relation between the Permissions junction table and the RolesToPermissions junction table. SQL server will not let me make this relation.

Is there any other way around this, or am I doing something wrong here.

OperationsTable ObjectsTable
--------------- -------------
opID(PK) objID(PK)
name name
\1 /1
\ /
\ /
\many /many

Permissions (Junction table)
-------------
opID(PK)
objID(PK)
permID(PK)

?1
?
? <-- error when making relation
?
?many

RolesToPermissions (Junction table)
-------------------
roleID(PK)
permID(PK)
|many
|
|
|
|1
RolesTable
----------
roleID(PK)
name


Thanks,
Abby

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 10/04/2012 :  16:24:36  Show Profile  Reply with Quote
i would have set pk of Permission table as just PermID

can you show how you created relationships?

I think it should be like

Permissions(objid) -> objects(objid)
Permissions(opid) -> operations(opid)
RolesToPermission(permid) -> permission(permid)
Rolestopermission(roleid) -> Roles (roleid)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000