Chapter 15

  1. It helps to ensure your data is consistent, accurate, and in the right format.
  2. You must ensure that you name things accurately, descriptively, and at the same time avoiding keywords that will add any kind of confusion to the naming. You must avoid adding spaces in the names, choose the right case, and stick to one convention. You should make sure that you use only permitted characters when naming a database object.
  3. If the data type is too large, it takes up too much space on disk. If the data type is too small, then it doesn't fit your data.
  4. There is no right number of indexes on a table or columns in your indexes. Generally speaking, too few or too many indexes can make the performance of your database worse. This is why it's important to know what queries are being executed on the table to understand best what would help the performance.
  1. The EXPLAIN keyword with your query or in the MySQL Workbench menu under Query, then Explain Current Statement
  2. Steps to write clean code are as follows:
  • Format it for readability.
  • Using uppercase for keywords and lowercase for everything else.
  • Adding comments.
  1. Some best practices when writing SQL statements are as follows:
  • Use SELECT fields instead of SELECT *.
  • Use column aliases, especially when using functions.
  • Avoid using SELECT DISTINCT.
  1. Some best practices when using the WHERE clause are as follows:
  • Only use wildcards at the end of a string.
  • Use an underscore (_) wildcard instead of a percent sign (%) when possible.
  • Avoid WHERE clauses with functions.
  • Use WHERE instead of HAVING to filter when possible.
  1. Always use column names in INSERT.
  2. If you are deleting all the data in a table, use TRUNCATE instead.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.27.45