0

I have a table to keep flights and i want to keep which days of the week this flight operates. There is no need for date for this since i only need day names.

Firstly i thought to have a column in the flight table that will keep a single string with the day names inside and use my application logic to unravel the information. This seems ok since the only operation on the days will be to retrieve them.

The thing is, i don't find this is "clean" enough so i thought of making a separate table to keep all 7 day names and a many to many (auto generated) table to keep the flight_id and day_id.

Still though, there are only 7 set values on days table and i am not so sure for the second approach either.

What i would like is some other opinions on how to handle this.

  • A flight can operate on many different days of a week
  • Only day names are needed - so, 7 in total.

Sorry for bad English and if this is a trivial question for some. I am not too experienced in both English language and databases.

1 Answer 1

0

Some databases support arrays. PostgreSQL for example supports arrays.

You could store the days in an array of integers and use a function to tanslate integers to day names. You could also use an array of a custom enum type (PostgreSQL Example).

1
  • I am using mySQL. After your answer i searched for a similar data type and i found SET to be the closest to what i was looking for. Thanks
    – Blm33
    Nov 17, 2012 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.