Skip to content

Instantly share code, notes, and snippets.

@paulghaddad
Created February 5, 2015 14:23
Show Gist options
  • Save paulghaddad/22b50d936399b66989f6 to your computer and use it in GitHub Desktop.
Save paulghaddad/22b50d936399b66989f6 to your computer and use it in GitHub Desktop.
LevelUp 6: Appropriately sizes database columns
1. Explain the problem with default column sizes and why we try to size columns properly.
Using default column sizes leads to an increased database size. If a column is larger than necessary for a column, the database will be larger than it should be. Suppose a column stores state abbreviations. If the column type is "text" instead of "char(2)", each record will use much more space than necessary, not only in the database but in the index, too (if it is indexed). When this occurs in a database with many columns and records, it leads to the following problems:
- The database size is much larger than it needs to be.
- The database is less efficient when performing queries because it must store and index larger column sizes.
In addition, using a variable column size when a fixed one will do leads to inefficiency.
Therefore, using the default column sizes without thinking through the requirements of the data leads to wasted resources and a less efficient database.
2. Contrariwise, explain the dangers of sizing columns inappropriately.
The increased storage and resource usage discussed above apply to inappropriately sized columns. Columns should be sized to the requirements of the data. Column definitions should be as small as possible but no smaller. If columns are sized properly, it leads to a less efficient database.
3. Make sure your yadda schema is well normalized and sized.
Completed first, second and third normal form normalizations on my Yadda database. I also properly sized the columns.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment