I have a gym and I'm using Pk
so all gym members have their own ID.
- Can I use other
PK
in the same table? - For example: to prevent
Número da Matricula
or evenCPF/RG
are repeated, can you addPK
to them?
I have a gym and I'm using Pk
so all gym members have their own ID.
PK
in the same table? Número da Matricula
or even
CPF/RG
are repeated, can you add PK
to them? It is not possible to have more than one PK
in the same table. Use Constraints, in your problem use the UNIQUE restriction, which will ensure that all values in your column be different.
UNIQUE
UNIQUE
uniquely identifies each record in a
table of a database. UNIQUE
and PRIMARY KEY
guarantee uniqueness in a
column or set of columns. PRIMARY KEY
constraint automatically has a constraint
UNIQUE
set. UNIQUE
in a table, but only one
Primary Key per table . Is it possible to use other PKs in the same table? - No, what you can use is the PK of another table as FK (Foreign Key) from another table. Another possible way would be to use a primary key composed of 2 fields. Example: TabItem PK - idItem
TabTipo PK - Type
TabTipoItem PK - IdItem PK - Type
To prevent the Registration Number or even the CPF / RG from being repeated, can you add a PK to them?
You can use the field as Unique so that the values will not be repeated.
It is not possible to have more than one primary key per table, it is the column or set of columns that identify a row.
To prevent repeated values from being inserted into certain columns, make it a unique key
.