Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
Is having the foreign key as the primary key a good idea in this situation?

I have a main user table which has some common attributes of a user (name , email, phone) and then I have 2 more tables (lets say x and y) that contain the different attributes of the two types of users. You may say (x1, x2, x3) and (y1, y2, y3). One user may only be of one type. I have an 'user_id' column in the x and y table and a primary key column. the 'user_id' column references the 'id' column in the user table. Would it be correct if I remove the 'id' column (which serves as primary Key) in the x and y table and instead used the 'user_id' column as the primary and forign key. im using postgres 9.6.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Your scenario is perfectly fine , no problem with that. It is known as super-type and sub-type in database terminology .

To read more about that , visit the link .

http://sqlmag.com/t-sql/sql-design-supertypes-and-subtypes

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!