Chanaka Lakmal
Chanaka Lakmal

Reputation: 1122

Best way to storing week days in MySQL database

I would like to know the most efficient datatype of storing days (SUNDAY, MONDAY etc.) of the week in a MySQL database. I want to search using that field and it will be used frequently.

I want to show the days as SUNDAY, MONDAY etc. in the GUI also. So, is it ok to use VARCHAR and store it as same as the name of the day or store it as TINYINT and convert when showing in the GUI?

Upvotes: 1

Views: 925

Answers (1)

SAUMYA
SAUMYA

Reputation: 1544

I think it should be

CREATE TABLE DAY_TABLE
(
 -- other fields
  EVENT_DAY ENUM('SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY')
);

Upvotes: 2

Related Questions