Reputation: 1
I have an Sql database in my C# program since c# allows you to build database inside the program. The question can an attribute(column) in a database be a range. for example, can I have attribute for the weight such as one of its values 120-130, so that it's more easy than specifying 10 values.
Upvotes: 0
Views: 77
Reputation: 85116
I assume you are talking about the Server Explorer in Visual Studio. If you are talking about a SQL Server database that is being used by your application this can be done using the a constraints.
If you add two, one that checks that Weight > 129 and one that checks that Weight < 131, it should prevent people from entering values outside of those ranges.
That said I would probably enforce this business rule through your C# Application logic rather than in the Database structure.
In other words present people with a drop down list to select from that contains only the range of values that you want. You could do server side validation on the selected values if security is a concern.
Upvotes: 0
Reputation: 1437
You could use two columns: Min and Max.
Name | Min | Max
--------------------
Item 1 | 120 | 130
...
Upvotes: 1