1,014 B
		
	
	
	
	
	
	
	
			
		
		
	
	
			1,014 B
		
	
	
	
	
	
	
	
| categories | tags | ||
|---|---|---|---|
  | 
  | 
Primary key
Every table in a relational database should have a primary key. A primary key is one field that uniquely identifies each record.
This is essential for carrying out operations across database tables and for creating and deleting database entires. It is also a safeguard: it means you can always identify a record by itself and don't have to rely on generic queries to identify it.
Sometimes you will have a dedicated field such as UNIQUE_ID for the primary key. Other times you can use an existing field to fulfil that function. In both cases the following constraints must be met:
- No two records can have the same primary key data
 - The primary key value should never be reused. Thus, if a record is deleted from the table, it should not be re-allocated to a new record.
 - A primary key value must not be modified once it has been created
 - A primary key must have a value; it cannot be 
null