What are the differences between primary, foreign, and unique keys?

a.       Primary Keys:

                                                              i.      Primary key uniquely identify each row in the database table.

                                                            ii.      Primary keys must contain unique value.

                                                          iii.      We can have only one primary key in a table.

                                                           iv.      Values in primary keys cannot be NULL.

b.      Foreign Keys:

                                                              i.      Foreign key is a key which points to a primary key in another table to create relation between two tables.

                                                            ii.      We can have more than one foreign key in a table.

                                                          iii.      Foreign key can accept multiple NULL values.

c.       Unique Keys:

                                                               i.      The Unique key uniquely identifies each record in a database table.

                                                            ii.      We can have more than one unique key in a table.

                                                          iii.      Unique key can accept only one NULL value

 
About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2024 CodingFusion
50+ C# Programs for beginners to practice