Defining constraints

  • Thread starter Thread starter Tom Archer
  • Start date Start date
T

Tom Archer

I have a table where I want to store either a location to
a picture (such as a URL) or the actual binary data that
comprises the picture. Since these are two drastically
different data types (string and binary, respectively)
I've defined a column for each possibility.

How do I define a constraint that enforces a rule stating
that one of the columns must have a value and the other
must be null (typical XOR situation) or do I have to do
this manually by subscribing to the data adapter's
RowUpdating event?
 
One way is to create a trigger on INSERT and UPDATE that verifies one of the
two fields has a non-null value.

You could _probably_ also do it on the Check constraint, but I've only dealt
with individual columns on Checks before - it seems reasonable both
logically and syntactally. I'd prefer this over a trigger, personally.

- Rick
 
As I'm using a disconnected dataset, I need something
client side. I was hoping that there was an easy way to
define a Constraint object to do this.

Thanks anyway,
Tom
 
Back
Top