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.
Remediation
Check the statement and if so, add primary key.
Violation Code Sample
The following statement should be reviewed:
create table SQLAMDA001_7_TBL1
(category_name varchar2(10) not null ,
title varchar2(50) null ,
title_id varchar2(10) null ,
author_name varchar2(30) null
)
/
Fixed Code Sample
The following statement should be reviewed:
create table SQLAMDA001_7_TBL1
(category_name varchar2(10) not null ,
title varchar2(50) null ,
title_id varchar2(10) null ,
author_name varchar2(30) null
)
/
Add a primary key:
alter table SQLAMDA001_7_TBL1 add constraint SQLAMDA001_7_TBL1_PK primary key (category_name)
using index
/
Reference
https://docs.oracle.com/cd/B28359_01/server.111/b28318/data_int.htm#CNCPT021 http://www.geeksengine.com/database/design/data-integrity.php https://www3.ntu.edu.sg/home/ehchua/programming/sql/Relational_Database_Design.html Exceptions : DB2 global temporary tables and Oracle private temporary tables do not support primary keys https://www.ibm.com/developerworks/data/library/techarticle/dm-0912globaltemptable/index.html https://oracle-base.com/articles/18c/private-temporary-tables-18c
Related Technologies
Technical Criterion
Architecture - Multi-Layers and Data Access
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.