Jason7261
Jason7261

Reputation: 145

Which data types should I use?

I am unsure of which data types to use for the following attributes:

Im not sure of whether to use CHAR or VARCHAR for some of these, or if there is another type I should use.

Upvotes: 1

Views: 724

Answers (3)

Nit
Nit

Reputation: 239

  1. INTEGER (Always used for numeric numbers) (If you are allowing "+" & etc. use VARCHAR)
  2. CHAR (for characters)
  3. INTEGER (as mentioned above)
  4. VARCHAR (It accepts both the character and the number)

Note: You should use "varchar" for all you needs.

Upvotes: 2

Suhail Mushtaq
Suhail Mushtaq

Reputation: 81

Understanding the difference between Char, Varchar will help you out.

  • Char is fixed length.
  • Varchar is variable-length. So in case, you have some fixed length variables like Gender, you can go with char, If you have some variable length variable like Name in your case, you can go with Varchar.

Upvotes: 1

Neel Bhanushali
Neel Bhanushali

Reputation: 782

  1. phone number -> decimal(10, 0)
  2. name -> varchar(length)
  3. productId -> integer unsigned (you can use autoincrement)
  4. location -> enum('possible value 1', 'possible value 2', ...)

Upvotes: 1

Related Questions