There are many databases like RDBMS, GRAPH DATABASE, etc…
Relation–>Table (One way to think about databases in contex of rdbms is think about Table).
Cust_id |
Cust_name |
Cust_Address |
Cust_ZipCode |
1 |
Peter |
202, Pt, Lane 3 |
20033 |
2 |
Alex |
304/34, St |
233456 |
3 |
Mark |
Jer 34, H.N 34 |
234532 |
4 |
Joe |
456/345 |
232323 |
Table: A set of rows and column
Column: Field/ Atribute(Most common terms)
Rows: Toupls/Records
Instance: Set of touple/rows along with the table structure. So, number of instance = number of touples/records/rows
Key: Minimum set of atributes/column to uniquely identify a touples/rows
Here Cust_Id is he Key which is uniquely identify the rows but the combinaion of Cust_Id + Cust_name is not is not a Key because we dont need both of them to uniquely identify the toples/row/record.
Lets take another exaple:
Cust_name + Cust_Address is the Key because separately Cust_name & Cust_Address can not able to uniquely identify the any records becase Cust_name may be duplicated or address may be duplicated but the combination of both willbe able to identify the unique record in the table.
Simple Key: The Key having one attribute is called as Simple Key
Compound Key: Key with multiple atributes is called as compound key. For ex. Cust_name + Cust_Address
Candidate Key : Set of all unique key is called as Unique Key
{Customer_id, {Cust_name + Cust_Address }}
Primary Key: One of the Candidate Key that DB-Designer chooses to maintain the uniqueness.
Rule for Primary Key:
1: Can not be null for any tuples
2: Atmost one primary Key
3: Unique for each row/tuple