﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / check constraint opinion? / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 22 May 2013 06:52:15 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: check constraint opinion?</title><link>http://www.sqlservercentral.com/Forums/Topic1364159-391-1.aspx</link><description>An alternative to CHECK constraints are Foreign Keys referencing lookup tables. These are useful when you need to validate that a value in a column is within a set and that set may need to be changed periodically. For example if your company ships to customers in the USA and Canada you could have a CHECK constraint on the [i]Country[/i] column in your [i]CustomerAddress[/i] table that made sure that was the case, however if you think you may someday ship to Mexico you may instead want to create a table named Country, add rows for USA and Canada and reference it using a Foreign Key. The, when you start shipping to Mexico you simply add a row to the [i]Country[/i] table and from that opint forward you can add rows to [i]CustomerAddress[/i] using the new country code.</description><pubDate>Wed, 26 Sep 2012 14:46:55 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: check constraint opinion?</title><link>http://www.sqlservercentral.com/Forums/Topic1364159-391-1.aspx</link><description>[quote][b]sqlguy-736318 (9/25/2012)[/b][hr]What's your opinion on check constraints in SS?Check constraints seem good for enforcing constraints at the table level.  Putting validation at other levels does not prevent a user from directly entering invalid data in the database.However, can check constraints potentially slow the database down or create other issues?[/quote]I am not 100% sure what you are looking for as an answer but...yes check constraints can potentially slow down the database. In fact, they will slow it down. The more important question is how much. Check constraints are usually really really fast to the point that the performance difference is unnoticeable and even difficult to measure. As a DBA it is your job to ensure the data. If that means that only values in a certain range or something like that then you should use check constraints. This is one of the ways as a DBA you have of ensuring that garbage data does not get in the system. I would never trust the validation outside of the database to be consistent. You just need to be sure that whatever constraint you establish is in line with the data requirements.</description><pubDate>Tue, 25 Sep 2012 12:10:24 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>check constraint opinion?</title><link>http://www.sqlservercentral.com/Forums/Topic1364159-391-1.aspx</link><description>What's your opinion on check constraints in SS?Check constraints seem good for enforcing constraints at the table level.  Putting validation at other levels does not prevent a user from directly entering invalid data in the database.However, can check constraints potentially slow the database down or create other issues?</description><pubDate>Tue, 25 Sep 2012 10:05:29 GMT</pubDate><dc:creator>sqlguy-736318</dc:creator></item></channel></rss>