Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7823057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:06:51+00:00 2026-06-02T08:06:51+00:00

I have have 2 tables User and Group . I have a table Attributes

  • 0

I have have 2 tables User and Group.
I have a table Attributes shared by user and group with columns:

  • attributeName.
  • AttributeValue.
  • ObjectID.

ObjectID points to either the primary key of user or the primary key of Group.
I have added a foreign constraint with Cascade on Delete in order to delete automatically the attributes when user or a group is deleted.

The problem now is when I insert an attribute for the user, I have a foreign key constraint because the group does not exist.

How should I proceed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:06:54+00:00Added an answer on June 2, 2026 at 8:06 am

    You have basically 3 options:

    1. Keep your current design, but replace Attribute.ObjectID with UserID and GroupID, attach a separate FK to each of them (one towards Group and the other towards User) and allow either to be NULL. You’d also want a CHECK constraint to ensure not both of them are NULL.

      enter image description here

    2. Split Attribute table to UserAttribute and GroupAttribute, thus separating each foreign key into its own table.

      enter image description here

    3. Use inheritance, like this:

      enter image description here

    The solution (1) is highly dependent on how your DBMS handles UNIQUE on NULLs and both (1) and (2) allow the same AttributeName to be used for two different attributes, one for user an the other for group.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 tables - user, service and ratings. The user's primary key is
Say, I have two tables like these: Table group Table user +----+-----------+ +----+----------+------+----------+ |
Suppose I have three tables: user , group and xref , a table that
I created 3 tables: User User-Group Group Where I can have a many-to-many relationship.
I'm setting up a group / user based security system. I have 4 tables
I have two models, user and group. I also have a joining table groups_users.
I have five tables: tab_template template_group group user_group user Tab_template's are organized into groups
In a database I have the tables User , Group and UsersInGroup and generate
I have these tables: USER TABLE uid | name | role | | 1
I have a table like so: Table eventlog user | user_group | event_date |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.