Dies ist eine alte Version des Dokuments!
LU03.L01 - Choose data-types
Task a) Choose datatypes
Which datatype would you use to store the following information? Give reason for your decision.
- product-title like trousers up to 50 characters:
- VARCHAR(50)
- Titles can be at the most 50 characters. A fix length makes not sense in that case.
- product-description up to 255 characters:
- VARCHAR(255)
- The description can be 255 characters, but can also be shorter. A fix length does not make sense in that case.
- stock amount:
- INT or INTEGER
- Floating point type is not suitable as pieces are always counted in whole numbers.
- price of each piece:
- FLOAT(5,2) or DECIMAL(U5,2)
- Prices have floating point
- The length of (5,2) should be sufficient enough as trousers are usually within a price ranger of 0.99 to 999.99.
- order date:
- DATETIME or TIMESTAMP
- The type depends on whether we want to safe only the date, but also the time.
- Important is, that the in this case the storage of the current time.
- date of delivery: * whether organical or not: * <color #ed1c24>BOOLEAN
- As there a only two posibilites to store a boolean data-type is the correct data-type.
- usage category with only one character:
- As long as there is only one character to be stored the CHAR-type will work.
- Technically the CHAR-types allows all letters, digits (as letters) and special characters.