B
B
BonBon Slick2018-03-11 19:41:56
Database
BonBon Slick, 2018-03-11 19:41:56

What gives Primary Key?

What is PrimaryKey for if we have a unique Uuid field there?
What will it give?
Because I see no reason to make the primary_key field for each entity.
https://en.wikipedia.org/wiki/Primary_key


From Wikipedia, the free encyclopedia
In the relational model of databases, a primary key is a specific choice of a minimal set of attributes (columns) that uniquely specify a tuple (row) in a relation (table).[a] Informally, a primary key is "which attributes identify a record", and in simple cases are simply a single attribute: a unique id....

But the field is already required + unique. So do we need a primary key?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis, 2018-03-11
@sidni

But what about, relational links, triggers (CASCADE STRICT), auto-increment fields, etc. It
’s one thing that you personally don’t use them, and for many, all logic is built on this, you won’t go far in a normal relational database on an ordinary unique field

D
Draconian, 2018-03-13
@Draconian

As you have written on the link, PK is an attribute (s) by which a record can be uniquely identified, but at the same time a unique and mandatory attribute is not necessarily a primary key. Mandatory and unique is identical to the primary key at the technical level, but at the level of database logic (which should reflect the logic of the domain) this may not be the case.
In addition, by assigning primary and foreign keys, you help the optimizer to create a more optimal query execution plan, you can then use cascading deletes, and so on.
PS the dude in the video is really funny, business doesn't care about normal forms at all, but that doesn't mean it's a bad idea to use them just because you're using an ORM in your application. You can generally store records in one field, separating attribute values ​​with a comma, and everything will work fine ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question