Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Database Systems - Primary Keys and Foreign Keys
Play lesson

Database Systems with SQL - Full Course - Database Systems - Primary Keys and Foreign Keys

5.0 (0)
6 learners

What you'll learn

This course includes

  • 4.5 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

A primary key is a unique column, or group of columns, used to identify a row of data. When creating a table using SQL, specify which column or columns you want to be the primary key. The primary key values cannot be NULL and must be unique and identify to at most one row. If just one column is used as the primary key, that is called a simple primary key. Sometimes multiple columns, called a composite primary key, are necessary to uniquely identify a row. Composite primary keys surrounded with parentheses. A minimal primary key uses all the columns uniqueness. A foreign key is one or more columns that refer to a primary key. The data types of the foreign and primary keys must be the same, but the names may be different. Foreign keys have different rules than primary keys: Foreign key values may be repeated. Foreign key values must match up to a primary key value. Foreign key values can be NULL Foreign keys also have some special cases: - Multiple foreign keys may refer to the same primary key.  - A foreign key may refer to a primary key within the same table. - A foreign key that refers to a composite primary key (multiple columns) must also be composite.  Subscribe to Appficial for more programming videos coming soon. Also, don't forget to click LIKE and comment on the video if it helped you out!

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere