Importance of the primary key in a table.

Q18. Explain the importance of the primary key in a table with the help of a suitable example.

Ans. In a database, a primary key is very useful for uniquely identifying the data in a field. A table must contain at least one primary key, and each field with the primary key must contain a value. Further,the primary key field cannot contain NULL value. If you assign a primary key to the column of a table, it means that each field in the column contains a unique value.

Suppose, you have created a table named Student, which contains the fields Stud_Rollno, Stud_Name, Stud_Marks in Maths, Stud_Marks in English, Stud_Marks in Science, and Stud_Total Marks. Now, you want to add a primary key in the Stud_Rollno column. In that case, each value in thecolumn must be unique. You must also remember that a primary key column cannot have a NULL value.

Leave a Reply

Your email address will not be published. Required fields are marked *