Help us understand the problem. What is going on with this article?

SQL :Database Relationships

More than 5 years have passed since last update.

One to One Relationships

  • In a one-to-one relationship, a key will appear only once in a related table.

image
image
image
image
image

One to Many and Many to One Relationships

  • In a one-to-many relationship, keys from one table will appear multiple times in a related table.

image
image
image
image

Many to Many Relationships

  • In some cases, you may need multiple instances on both sides of the relationship.

image
image
image
image
image
image

Self Referencing Relationships

  • Customers can refer other customers to your shopping website.

image
image

Foreign Keys

  • we always had these "****_id" fields that referenced a column in another table.

image

  • Defining the Foreign Key Explicitly

image
image
Without Explicit Declaration
image

  • Visualizing the Relationships in MySQL Workbench

image

  • Detail

  • shortcuts
    Screen Shot 2015-11-04 at 16.30.47.png
    relationshipSymbols.png

  • Non-identifying relationship
    A non-identifying relationship means that a child is related to parent but it can be identified by its own.
    image
    image

  • Identifying relationship
    An identifying relationship means that the parent is needed to give identity to child. The child solely exists because of parent.
    image
    image

aucfan
あらゆる商品に関する正確でフェアな情報を提供する企業として、世界における唯一無二の存在となるというビジョンの元、基盤となる技術を作り続けるマザーズベンチャー
https://aucfan.co.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away