TIL(11/8) - Starbucks Database Modeling

xxhaileypark·2021년 11월 9일
0

TIL

목록 보기
2/8
post-thumbnail

We practiced a database modeling with the starbucks beverages page as below.

First, We needed to list up the each information and look for the repeated ones.
And then we separated the information as a different table and drew a line which refers to the other table's information.

The result of mine is as below.

And following is the best example our mentor showed.

->We could see that the allergen and product(drinks) are many to many relation so have a junction table.

There were some more basic rules to make the tables look easier refering to the best example above.

  1. Table name should be in lowercase and in a plural form.

  2. column name should be in snake case (snake_case)

  3. The name of a Foreign Key should be in a singular form of the name of the table it refers to, adding "_id"
    For example, as you could see in the best example of the Starbucks modeling, if the Foreign Key refers to the "categories table", the name of the Foreign Key should be "category_id".

  4. If we could notice the information from the table name, then we don't have to put it in the column name.

  5. We should consider the expandability when we do database modeling.
    For example, as you could see in the best example of the Starbucks modeling, we better make a separate table for "images" if we think that there will be more images added later.

profile
I'm a deeply superficial person.

0개의 댓글