Dies ist eine alte Version des Dokuments!


LU03.L01 - Choose data-types

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:
    • 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.
  • 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.
  • organical or not:
    • BOOLEAN
    • As there a only two possibilites to store a boolean data-type is the correct data-type.
  • 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
respectively beziehungsweise

Volkan Demir

  • modul/m290/learningunits/lu03/loesungen/l01.1723636704.txt.gz
  • Zuletzt geändert: 2024/08/14 13:58
  • von vdemir