S
S
Sergey Dyudin2020-06-16 13:11:16
PostgreSQL
Sergey Dyudin, 2020-06-16 13:11:16

How to properly design a table?

There is a one-to-many relationship and therefore decided to move the field to a separate table. The field
itself will be of one type (varchar(20) with unique values) and there will be several dozen records in this table. Do I need to create an additional field such as id, make it PRIMARY KEY and be referenced by another table? Or is it better to leave the table with one field and directly refer to type?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Vakhrushev, 2020-06-18
@IvanVakhrushev

If we put it in a separate table, then there must be a surrogate PK.
If PK is not added, then there is no point in moving this field to a separate table.
PS I wouldn't put it in a separate table at all, so as not to make unnecessary connections in the future.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question