There are four basic constraint in relational model. These constraints will be explained respectively.
1. domain constraint :
Each set of attributes has an atomic value, which is in the domain.
2. key constraint :
All tuple in a relation must be distinct. In other words, you can find a column which does not have the same elements in it.
3. Entity Integrity constraint :
The column which is be regard as a key can not have an element that is 'Null'.
4. Referential Integrity constraint :
Suppose that we have a set of attributes FK in relation schema R1 which is a foreign key of R1 that references R2.
D(FK) = D(PK) PK is the primary key of R2 ( Both domain must be the same. In other words, it should be the same set)
t1[FK]=t2[PK] or t1[FK] is NULL , The value R1 wants to reference must exist in R2
There are some other constraints established by future generations.
Semantic integrity constraint : ( 語意限制 )
The constraint established by the developer when making the database. For example, every students' class is between 1 to 10. If the number in the column of class No. was bigger than 10 or smaller than 1, the semantic integrity constraint has been violated.
When you are designing a database, you have to give a condition to the computer to let it know when to detect whether the constraint has been violated or not.
This kind of constraint can be static or dynamic. The example mentioned above is static. The following example is a dynamic constraint. The grade of the student can not be smaller than before. Maybe someone will be confused about why it is a dynamic constraint. It is because the base will be changed by the year you're in school.
The picture below is an example relational model.
My English is really poor. If there is any mistake about the grammar, please accept my apology.
If you want the process of changing ER model to relational model, please PM me. I'll find a way to give it to you.