Store days of week in a database
asp.net-mvc-3, database, sql, sql-server
Solution
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/...
Problem
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.