# ERD

# Entities

image-20210126212148687

Entities are the rows attributes are the columns in the database.

# Cardinality

image-20210126212304339

image-20210126212550831

# PK

Primary Key is a unique attribute that identifies every record in a certain table.

You need 1 primary key per entity.

Rules

  1. Unique
  2. Never changing
  3. Never Null

# FK

Primary Key that is referenced in another entity.

There can be multiple FKs in one entity.

image-20210126213324690

# Composite PK

When you combine keys to make a PK

image-20210126213458016

image-20210126213523936

Two show composite PK, you put two PK in front of the keys. But this does not mean it has two primary keys.

Rules

  1. Use the fewest number of attributes possible
  2. Don't use attributes that are apt to change

# Why not use shipment ID?

You could. Some people hate composite PKs. Depends on the scenario.

# Bridge Tables

# Why not just create many to many relationship?

image-20210126213815589

If you create such relationship, you will be missing a lot of information such as 'when' the order was made. That's when the bridge table comes in.

# Datatypes

image-20210126214022006

Last Updated: 3/1/2021, 9:19:08 PM