No products in the cart.

Explain primary and foreign key with …

CBSE, JEE, NEET, CUET

CBSE, JEE, NEET, CUET

Question Bank, Mock Tests, Exam Papers

NCERT Solutions, Sample Papers, Notes, Videos

Explain primary and foreign key with example
  • 2 answers

Swati Rajpoot 3 years, 8 months ago

What is the Foreign key? FOREIGN KEY is a column that creates a relationship between two tables. The purpose of Foreign keys is to maintain data integrity and allow navigation between two different instances of an entity. It acts as a cross-reference between two tables as it references the primary key of another table. Example: DeptCodeDeptName001Science002English005ComputerTeacher IDFnameLnameB002DavidWarnerB017SaraJosephB009MikeBrunton In this key in dbms example, we have two table, teach and department in a school. However, there is no way to see which search work in which department. In this table, adding the foreign key in Deptcode to the Teacher name, we can create a relationship between the two tables. Teacher IDDeptCodeFnameLnameB002002DavidWarnerB017002SaraJosephB009001MikeBrunton This concept is also known as Referential Integrity.

Swati Rajpoot 3 years, 8 months ago

PRIMARY KEY is a column or group of columns in a table that uniquely identify every row in that table. The Primary Key can't be a duplicate meaning the same value can't appear more than once in the table. A table cannot have more than one primary key. Rules for defining Primary key: Two rows can't have the same primary key value It must for every row to have a primary key value. The primary key field cannot be null. The value in a primary key column can never be modified or updated if any foreign key refers to that primary key. Example: In the following example, <code>StudID</code> is a Primary Key. StudIDRoll NoFirst [email protected]@gmail.com313DanaNatanmno@yahoo
http://mycbseguide.com/examin8/

Related Questions

Define goal seek
  • 1 answers

myCBSEguide App

myCBSEguide

Trusted by 1 Crore+ Students

Test Generator

Test Generator

Create papers online. It's FREE.

CUET Mock Tests

CUET Mock Tests

75,000+ questions to practice only on myCBSEguide app

Download myCBSEguide App