Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Your first table
6. How tables work - continued
Entity Relationship Diagrams (ERD)
DROP - how to remove a table


Good. Now, let's go deeper into table structure. Each column stores a certain type of data. Some columns store numbers (price, quantity, id), other columns store text (names, descriptions) or dates.

Why do we need to specify data types for columns? Couldn't there be one general data type for everything? Well, internally, our database performs a lot of bookkeeping. It needs to know how much space it should have for the data in a given column. A longer text requires more space than a short number, for example.

What's more, the database has many additional structures which make it run faster, like row sorting. Numbers are sorted differently than text. This is why we need to specify column types each time we add a column to a table.


Let's experiment with data types a little bit. In our table exhibit, there is a column id which contains the identification number of the toy. The data type has been chosen to allow number values only. Let's try to insert a row with some text in that column and see what happens.