Lesson Tuesday

Here is a review of database naming conventions:

  • All names (databases, tables, columns, etc.) should be in lowercase.

  • Table names should always be plural. For example, we'd name a table tasks, not task.

  • Names with multiple words are separated by an underscore. For example, date_of_birth is the correct syntax, not dateofbirth. Make sure to avoid dashes as well as they will cause errors.

  • If a join table doesn't have any meaning besides just joining two tables, use table_a_table_b with the names in alphabetical order. Example: cuisines_restaurants would be a join table for the table cuisines and restaurants.

  • If the table has meaning besides just joining the table, use a name that describes the relationship. Example: visits would be a good name for a join table that joins together a table called people and a table called places.

  • If you add in a foreign key to your table (i.e. the column list_id into the tasks table), the foreign key is a singularized version of the table it represents. For example, list_id not lists_id.

Lesson 22 of 29
Last updated August 7, 2022