How to build a constraint on a column when an insert in performed.
Posted on 2014-11-16
Suppose I have two tables, as listed below
How can I put a constraint on the "FullName" column of Table_2, such that
that FullName in Table_2 never contains a name which is the same as a first name which might exists in the FirstName column of Table_1?
The purpose is to prevent someone from entering just a first name in the FullName column, instead they should be entering two names for the full name FirstName + LastName.
Ignore the fact that someone might just have one name (Sausquach, Prince, Bono) such as a performer.
In this hypothetical situation I need a first name plus a last name.
So how does one go about building such a constraint? Would I need a sql script of function to query the FirstName column of Table_1, each time a FullName value is entered into the FullName column of table 2 ?
Table_1 : (FirstName and LastName are the primary key)
FullName (Put a constraint on this column, so that the a first name never appears in this column)