Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Database Systems - Foreign Key Example - How to use the FOREIGN KEY Constraint
Play lesson

Database Systems with SQL - Full Course - Database Systems - Foreign Key Example - How to use the FOREIGN KEY Constraint

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

The FOREIGN KEY constraint specifies which column to use as the foreign key, which is typically a primary key to another table. You can apply rules or constraints to your database table when you create it with CREATE TABLE, or later on with ALTER TABLE. Example: CREATE TABLE Director ( DirectorID SMALLINT UNSIGNED AUTO_INCREMENT, FirstName VARCHAR(50), LastName VARCHAR(50), PRIMARY KEY (DirectorID) ); CREATE TABLE Movie ( MovieID SMALLINT UNSIGNED AUTO_INCREMENT, DirectorID SMALLINT UNSIGNED, Title VARCHAR(100), PRIMARY KEY (MovieID), FOREIGN KEY (DirectorID) REFERENCES Director(DirectorID) ); 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