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)</color>
- Titles can be at the most 50 characters. A fix length makes not sense in that case. * product-description up to 255 characters: * <color #ed1c24>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 * <color #ed1c24>The type depends on whether we want to safe only the date, but also the time. * <color #ed1c24>Important is, that the in this case the storage of the current time. * <color #ed1c24>date of delivery: * whether organical or not: * <color #ed1c24>BOOLEAN
- As there a only two posibilites to store a boolan data-type is the correct data-type. * usage category with only one character: * <color #ed1c24>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.