Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda