I’m using a SQL Server database, I’m working on a real estate website.
I have a table listing the properties with a column called SIZE.
A user can optionally input a SIZE value for a property (only integral and positive numbers).
At the moment I’m using this
int Size NULL
I would like to know:
- If NULL value in this case would make sense (I read some article that discourage the use of NULL so I would like if this is the case)
- The value of size should be from 0 to 100000, I would like to know if the datatype
Intis appropriated.
Please if you consider this question inappropriate just comment, I would remove it from the site.
Thanks
NULLis the “correct” approach, but it can make writing queries a pain, becauseNULLwon’t match any predicate exceptIS NULL. For example, say you want a query that finds all rows that have a size between x and y, but you also want to show rows that don’t have any size. Your query will look like this:This can introduce unnecessary complexity, and you also need to deal with how to render a null size.
A better option IMHO is to make the column
NOT NULLand force the user to input a size. That will simplify both your application and query code.Don’t tell me that customers own a property and don’t know how big it is.