What is a Foreign Key Constraint? Understanding Primary & Foreign Keys

Поделиться
HTML-код
  • Опубликовано: 13 июн 2024
  • In this short video we'll cover what foreign keys are, why they are important, how they differ from Primary Keys and how they function in a relational database.
    00:00 Introduction
    0:21 Example of Foreign Keys in a database
    0:32 What is a Primary key?
    1:19 What is a foreign key?
    2:02 What do foreign keys do?
    3:27 Review of Foreign Keys
    In this video, we are focusing on foreign keys that link one column in a table to one column (the primary key) in another table for the sake of simplicity. Your own use of a foreign key can be more complex: foreign keys can link to a compound (more than one column) in another table, and foreign keys do not have to link to another table's primary key.
    Just keep in mind that whatever your foreign key is referencing in the other table must have a unique constraint (this is why using a foreign key to reference another table's primary key is often a good idea, since we know that has a unique constraint by default).
    Next video: how to use foreign keys in SQL: • How to Create Tables w...
    More documentation on foreign keys: www.cockroachlabs.com/docs/st...
    #ForeignKeys #PrimaryKeys #RelationalDatabase #CockroachDB

Комментарии • 35

  • @maysa7491
    @maysa7491 Год назад +13

    wow
    u saved me a lot of time

    • @cockroachdb
      @cockroachdb  Год назад +3

      And you just made my day with this comment.

  • @morriskeller
    @morriskeller Год назад +6

    Perfect explanation. No Bloatware!

  • @abrahamhahijary
    @abrahamhahijary Год назад

    Clear and helpful, thanks!

  • @msingh5581
    @msingh5581 Год назад +1

    Best lecture to clear key confusions arising from definitions.

  • @junghabaek2046
    @junghabaek2046 2 года назад +3

    The best video. Thank you!

  • @hristohristov8283
    @hristohristov8283 2 года назад +4

    Very well explained and clearly illustrated. And I mean it!

  • @user-xs3kf9tx1m
    @user-xs3kf9tx1m Год назад +2

    Thank you for such a comprehensive way of presenting the information!

  • @2000rira
    @2000rira 2 года назад +7

    Well explained , Impressive illustrated 🤝Good job

  • @Sidra--
    @Sidra-- 5 месяцев назад

    Thank you so much!

  • @ahhindeed
    @ahhindeed Год назад +1

    great explanation, thank you!

  • @skincarver666
    @skincarver666 3 месяца назад

    great video

  • @bradleyli1569
    @bradleyli1569 10 месяцев назад

    Concise and comprehensive explanation! Thanks very much!

    • @cockroachdb
      @cockroachdb  10 месяцев назад

      We're happy to hear that it helped!

  • @rafco90
    @rafco90 Год назад

    Excellent explanation!

  • @timdavis8951
    @timdavis8951 Год назад +1

    Clear, basic, thanks!

    • @cockroachdb
      @cockroachdb  Год назад

      Thanks for watching Tim. Let us know if there are other concepts that you think would be helpful to learn about in this format.

  • @purpledragon9413
    @purpledragon9413 9 месяцев назад

    Thank you! I couldn't understand this concept from the Coursera course I'm taking. Your video effectively cleared my confusion!

    • @cockroachdb
      @cockroachdb  9 месяцев назад

      We're so glad to hear that this video helped clear your confusion.

  • @jesperhjholdt7871
    @jesperhjholdt7871 2 года назад +3

    Thank you!'

  • @heberrepiso2836
    @heberrepiso2836 2 года назад +2

    Excelllent video.

  • @shenshaw5345
    @shenshaw5345 Год назад +1

    Really great explantion

  • @igorg.8624
    @igorg.8624 2 месяца назад

    Is there a way to use this concept to avoid duplicating data across tables? For example - there is an Orders table and a MyOrders table. I'd like MyOrders table to automatically reference Orders without duplicating the data in it....

  • @-.-_._--
    @-.-_._-- 5 месяцев назад

    Great but is it also possible that a column is both a primary key and foreign key in the same table

  • @gdejandespotovic
    @gdejandespotovic 2 года назад

    tnx

  • @senju31
    @senju31 2 года назад

    So it's not possible to insert data only into a parent table without having an error?

  • @shukes4645
    @shukes4645 Год назад

    it took me at least 30 minutes to find an understanding video. That doesn't have an overly thick uninteresting indian guy making 0 sense. And i finally found someone who explains it in under 10 minutes and is short, simple and awesome. Thank you very much

  • @sergiibritannica8957
    @sergiibritannica8957 2 года назад +6

    Clear and helpful, thanks!