I am developing a table of ownerships for files. Personal files could be possessed by whether single user (table Customers) or several customers (table UserGroups). I must get this to whole relationship as you table, where each tuple will be an group's possession or perhaps a user's possession of the file.

Customers: User_ID(PK), title, email
UserGroups: UserGrp_ID(PK), title, creator_ID(FK to Customers)

TestGroupOwnerships: ???

I believe you can do both associations as you table, but I am not quite sure how. It's also acceptable if Customers or UserGroups tables have to change (still within the planning stage).

Thanks,

Alex

You can:

  • allow NULL on FK posts
  • give a CHECK CONSTRAINT to make sure that certain of these is non-null:
ALTER TABLE dbo.MyTable ADD CONSTRAINT
    CK_MyTable CHECK (Column1 IS NOT NULL OR Column2 IS NOT NULL)
GO

enter image description here

Notes

  1. OwnerID = PartyID (OwnerId is really a role title of PartyID within the File table).
  2. UserID = PartyID (UserID is really a role title of PartyID within the User table.)
  3. GroupID = PartyID (GroupID is really a role title of PartyID within the Group table.)

What about:

Possess a table with (File,OwnerID (int),OwnerType(Char(1))

Where OwnerID may either be UserID or GropuID and OwnerType may either Be ('G' - Group or 'U' - User)

Or....

Possess a table with (File,OwnerID,GroupID) in which a touple which has OwnerID populated joins towards the user table along with a tuple with GroupID populated joins towards the Groups table.