Lesson Monday

Let's take a moment to review the important conventions and best practices we've followed so far. Read this lesson to review, then refer back whenever necessary. We'll be expected to follow these both throughout the rest of the course, and out in the field.

Database Best Practices Reference

  • All names for all database components (databases, tables, columns, etc) should always be in lowercase.

  • All SQL statements must end with a ; semicolon.

  • SQL commands must use single quotes, double quotes won't work.

  • Never, ever, ever delete databases that come with MySQL or other tools by default.

  • Table names should be plural versions of the objects they will hold. For example, items not item. Or puppies not puppy.

  • Names with multiple words are separated by an underscore. For example: date_of_birth not dateofbirth.

  • The column containing our primary key is almost always named id.

  • Test databases must have the same name as the production database, with the inclusion of _test at the end.

  • Test databases must contain the exact same schema as the development database. In order to ensure they're the exact same, we create our test databases by using our development database as a "template".

  • When a primary key of one table is added as a property on another table as a foreign key, it is always named the singular name of the table with _id following it. (For example, entries in our items table store which Category an Item belongs to with a category_id foreign key.)