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 7447255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:33:15+00:00 2026-05-29T12:33:15+00:00

I have 2 tables, User and Employee . Each user is given a User_ID

  • 0

I have 2 tables, User and Employee. Each user is given a User_ID and that is a primary key in the User table and a foreign key in the Employee table. Can that attribute in the Employee table also be a primary key?

  • 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-05-29T12:33:16+00:00Added an answer on May 29, 2026 at 12:33 pm

    If you have a one-to-one relation between two tables, then the primary key of the details table is a foreign key as well.

     master           detail (1 : 1)
    +----------+ 1:1 +-------------+
    | PK  id   |<---o| PK FK  id   |
    +----------+     +-------------+
    |     col1 |     |        col1 |
    |     col2 |     |        col2 |
    |     etc. |     |        etc. |
    +----------+     +-------------+
    

    If you have a m-to-n relation, the junction table has columns relating to the two primary keys of the m and the n-tables. These columns are primary keys and foreign keys at the same time.

                        m : n
     m_table          junction
    +----------+ 1:m +------------+      n_table
    | PK  id1  |<---o| PK FK1 id1 | n:1 +----------+
    +----------+     | PK FK2 id2 |o--->| PK  id2  |
    |     col1 |     +------------+     +----------+
    |     col2 |     |            |     |     col1 |
    |     etc. |     +------------+     |     etc. |
    +----------+                        +----------+
    

    Note that with this construction, a record of one table can only be linked to a specific record of the other table once, since each composite primary key of the junction table must be unique. If you want to allow non-unique pairings, define a separate primary key in the junction table:

                        m : n
                      junction
                     +---------+
     m_table         | PK  id  |
    +----------+ 1:m +---------+      n_table
    | PK  id1  |<---o| FK1 id1 | n:1 +----------+
    +----------+     | FK2 id2 |o--->| PK  id2  |
    |     col1 |     |         |     +----------+
    |     col2 |     +---------+     |     col1 |
    |     etc. |                     |     etc. |
    +----------+                     +----------+
    

    In this case, the primary key and foreign key constraints are set on different columns. Alternatively you can also build the primary key with the two foreign keys plus one numerator or another discerning attribute.


    In your case, if there is a one-to-one or a one-to-zero-or-one relationship between User and Employee, then yes, the User_ID in the Employee table can be Foreign Key (FK) and Primary Key (PK) at the same time. In words, this would mean: A user can be an employee as well, in which case the employee data would be attached to the user. If he is not an employee (he could be an external expert), no employee record is attached. If User_ID is FK and PK in Employee, each user can have at most one employee record attached. If User_ID was only FK but not PK in table Employee then a user could have several related employee records.

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

Sidebar

Related Questions

I have three tables: User, Employee and Worker. User table has one-to-zero-or-one relationship with
Take tables: User, Comment, Snippet. A User can have many Snippets. A Snippet can
I have 2 tables employee_master & user_master Employee_id is a foreign key in user_master.
I have simple LINQ problem that I can't figure out. I have a table
I have five tables: User user_id | name -------------------- 0 | Mark 1 |
I have three tables: User: UserId (pk) FirstName Lastname Messages: MessageId (pk) Heading Body
I have 2 tables - one storing user information (id, username, password) and the
i have in the database typical tables like user, usergroup, and they have relations.
I have 3 tables users(id,name),groups(id,name) and users_groups(user_id,group_id). users and groups have many to many
Let's say I have four tables: PAGE , USER , TAG , and PAGE-TAG

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.