LoginSignup
1
1

More than 5 years have passed since last update.

SQL :Database Relationships

Last updated at Posted at 2015-11-05

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

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1