LU04.S01 - Choose data-types

Which datatype would you use to store the following information? Give reason for your decision.

1. Product-title like trousers up to 50 characters:

  • VARCHAR(50)
  • Titles can be at the most 50 characters. A fix length like a simple CHAR(50) makes no sense in that case.

2. 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.

3. Stock amount:

  • INT or INTEGER
  • Floating point type is not suitable as pieces are always counted in whole numbers.

4. Price of each piece:

  • FLOAT(6,2) or DECIMAL(6,2)
  • Prices have floating point
  • The length of (6,2) should be sufficient enough as trousers are usually within a price ranger of 0.99 to 9999.99.

5. Order date:

  • DATE or DATETIME
  • The type depends on whether we want to safe only the date, but also the time.
  • Usually in such cases to store only the order-date is enough.

6. Date of delivery:

  • DATETIME or TIMESTAMP
  • Regarding delivery quality the criteria punctuality might be one key element. Therefore the storage of the delivery-time is compulsory.

7. organic or not:

  • BOOLEAN
  • As there a only two possibilites to store a boolean data-type is the correct data-type.

8. Usage category with only one character:

  • CHAR
  • 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.
English German
to give reason for begründen
at the most höchstens
stock amount Lagermenge
to float fliessen
sufficient ausreichend
regarding bezüglich
might be möglicherweise
technically im Prinzip, eigentlich

Volkan Demir

  • modul/m290/learningunits/lu03/loesungen/l01.txt
  • Zuletzt geändert: 2024/10/17 12:32
  • von vdemir