, , , , ( ):
CREATE FUNCTION dbo.validateExpertise(
@expertise_type varchar(8),
@Expertise_animal varchar(30),
@Expertise_breed varchar(30)
)
RETURNS BIT
AS
BEGIN
IF (@Expertise_animal == 'dog' AND @Expertise_breed != 'dog')
RETURN 0;
RETURN 1;
END
GO
ALTER TABLE detailTable ADD CONSTRAINT chkExpertise
CHECK (dbo.validateExpertise(expertise_type, Expertise_animal, Expertise_breed) = 1)
, . ( ) - , ( ASP.NET MVC, WCF, - ..) ( , .
. , , FK s, unique , .., .
Also, keep in mind that restrictions like the ones mentioned above will be triggered for each INSERTor UPDATEin the table and can seriously degrade the performance of queries involving a large number of records.
source
share