On database systems, should each table have a primary key?
For example, I have a table table1(foreignkey1,foreignkey2,attribute), for example, it this.table1does not have a primary key.
table1(foreignkey1,foreignkey2,attribute)
this.table1
Should I define a primary key for this table, for example table1id?
table1id
This is a subjective question, so I hope you do not mind, I answer with some opinion :)
, - 95% + - , , . ( " " ) , , , .
, : "" "" . , . , . - , , MySQL , , , , .
, , , , , DMBS: " - , , !"
: , . , , .
, / :
.
Databse .
MySQL- PRIMARY KEY, , , .
Composite Primary key, :
CREATE TABLE table1( FK1 INT, FK2 INT, ATTRIBUTE INT, PRIMARY KEY (FK1, FK2) )
1:
ALTER TABLE table_name ADD CONSTRAINT pk_table1 PRIMARY KEY (FK1,FK2)
. , .
, :
, (foreignkey1, foreighkey2). , . , , , .
(foreignkey1, foreighkey2)
, . , , . , , , , . .
Source: https://habr.com/ru/post/1620881/More articles:Call Python function from Fortran / C - cRemoving wrapped lines - pythonCalling a Python function from a C program - c ++Python callback from Fortran - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1620880/r-ggplot2-how-do-i-increase-space-between-specific-geomtile-bars-to-group-them-in-pairs&usg=ALkJrhg34nPzIBkhdeiV7aM3GLD8Xw91XgPython queries: invalid header name - pythonHow to return value from Python callback to Fortran using F2Py - callbackSending a specific variable value for the link_to method in Rails - ruby-on-railsPyObject segfault when calling a function - c ++The sums of the subsets of a vector by indices stored as vectors in an array of cells - arraysAll Articles