I have to do a small project for school. What is the best possibility to store days of the week in a database table?
E.g. days of the week for data backup — should I use a column like this:
backupDays varchar(50)
1,5 >> monday + friday
2,3,4 >>tuesday + wednesday + thursday
I have to use this table in my asp.net MVC program and I use a MSSQL database.
In this case (7 boolean values in the one field) we get a binary set only 7 bits long. So you can use one byte length field type in MS SQL - tinyint. And use bitwise operators to manipulate it.
For example(binary):
00000001 -Sunday
00000011 - Monday and Sunday
00000101 - Tuesday and Sunday
00000111 - Monday,Tuesday and Sunday
Here you can find details and examples:
http://sqlfool.com/2009/02/bitwise-operations/
http://www.mssqltips.com/...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With