Primary Key

Posted in Information Technology & Systems, Total Reads: 332
Advertisements

Definition: Primary Key

In RDBMS (relational database management system) every row in a table is uniquely identified by one key or a set of keys named as primary key. Any row that enters into the table need to have primary key or composite primary key. Each table have got just one primary key and compulsorily it should be not null.

 

Prof_ID

Prof_Name

Dept.

Course Group

39404

Ashish

Marketing

Sec A

39445

Sonam

Product

Sec B

43576

Anu Priya

Finance

Sec C

54325

Anu Priya

Finance

Sec C

99823

Anushka

HR

Sec D

14325

Anushka

HR

Sec E


For example in above table prof_ID is the primary key. Suppose a new professor joins the institute then compulsorily he/she will be given unique identity number by which he/she will be identified.

 

Product Id

Shop Id

Product name

Price

Quantity in Kg.

1293

23

Rice

45

50

2341

23

Wheat

35

68

3365

45

Dal

65

43

3365

67

Dal

65

56

1293

89

Rice

45

44


Here as same product is available on different shops and a shop can have more than one products, so it’s difficult to store items using a single primary key. In such case a set of Product_Id and Shop_Id can uniquely determine a row and hence these two create a composite primary key.

 

Advertisements



Looking for Similar Definitions & Concepts, Search Business Concepts