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

  • Home
  • SEARCH
  • 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 3310430
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:45:33+00:00 2026-05-17T21:45:33+00:00

Lets say I have a table called Employees , and each employee has a

  • 0

Lets say I have a table called Employees , and each employee has a primarykey called (E_ID)
and I have another table called Positions , and each Position has a primarykey called (P_ID)
and I also have another table called offices , and each office has an ID called (O_ID)

Now I want to create a table that has three primaryKeys which are (E_ID) and (P_ID) and (O_ID) …
ofcourse these three values must be withdrawl from the first three tables , but I just can’t do it anyway ?
please help me because I neeeeeeed it badly
thanks verymuch

  • 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-17T21:45:34+00:00Added an answer on May 17, 2026 at 9:45 pm

    If it was me, I think I’d just add P_ID and O_ID to Employees. The same Position might be filled by multiple employees, and there might be multiple Employees at a given Office, but it’s unlikely (without using Cloning technology) that the same Employee would need to be replicated multiple times – thus, just add P_ID and O_ID to Employee and I think you’re good to go. Of course, you’ll need foreign key constraints from Employee to Position (P_ID) and Office (O_ID).

    EDIT: After some thought, and recalling that I’ve had jobs where I filled multiple positions (although at the same location), I suppose it’s conceivable that a single person might have fill multiple positions which might be at different locations.

    If you’re really set on having a junction table between Employees, Positions, and Offices – OK, create a table called EmployeePositionOffice (or something like that) which contains the three columns E_ID, P_ID, and O_ID. The primary key should be (E_ID, P_ID, O_ID), and each field should be foreign-keyed to the related base table.

    EDIT:
    Not sure about the SQL Server syntax, but in Oracle the first would be something like:

    ALTER TABLE EMPLOYEES
      ADD (P_ID NUMBER REFERENCES POSITIONS(P_ID),
           O_ID NUMBER REFERENCES OFFICES(O_ID));
    

    while the second would be something like

    CREATE TABLE EMPLOYEES_POSISTIONS_OFFICES
      (E_ID  NUMBER REFERENCES EMPLOYEES(E_ID),
       P_ID  NUMBER REFERENCES POSITIONS(P_ID),
       O_ID  NUMBER REFERENCES OFFICES(O_ID),
       PRIMARY KEY (E_ID, P_ID, O_ID));
    

    Share and enjoy.

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

Sidebar

Related Questions

Lets say I have one table called REVIEWS This table has Reviews that customers
Lets say I have a table in MySQL called articles, that has a column
To keep this simple, lets say I have two tables. The first is called
Hoping someone can help me out with this. Lets say I have a table
Lets say we have two databases, one named db1, the other one named db2.
Through various questions I have asked here and other forums, I have come to
Is it possible to change execution context to CALLER in a stored procedure, which
I'm working on a PostgreSQL 8.1 SQL script which needs to delete a large
I've looked through similar questions but I'm still a little perplexed about something that
On production our database is a few hundred gigabytes in size. For development and

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.