CRITICAL
Rule Definition
In relational database design, a candidate key is just a unique identifier. Next a primary key is a candidate key that's been singled out to uniquely identify each row in a table.
A unique key or primary key comprises a single column or set of columns. No two distinct rows in a table can have the same value (or combination of values) in those columns.
Depending on its design, a table may have arbitrarily many unique keys but at most one primary key.
=> Primary keys are defined in the ANSI SQL Standard, through the PRIMARY KEY constraint.
Remediation
Appy referential integrity through constraint::
Violation Code Sample
CREATE TABLE table_name (
id_col INT PRIMARY KEY,
col2 CHARACTER VARYING(20),
...
)
Fixed Code Sample
ALTER TABLE <table identifier>
ADD [ CONSTRAINT <constraint identifier> ]
PRIMARY KEY ( <column expression> {, <column expression>}... )
Reference
https://stackoverflow.com/questions/39649981/why-is-it-a-bad-idea-to-have-a-table-without-a-primary-key/39650093
Related Technologies
PL/SQL
Microsoft T-SQL
Sybase T-SQL
Technical Criterion
Efficiency - SQL and Data Handling Performance
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.