Hello friends! Let's consider, we have 3 tables: tabel1: ------- id | subjects | local_idx ------------------------- 1 | s1 | 1 2 | s2 | 25 3 | s3 | 14 ... A group has got some subjects only one time, e.g group a1 has subject s1 only one time: table2: ------- id | groups | local_idx | subjects --------------------------------------------------- 1 | a1 | 1 | s1 2 | a2 | 2 | s1 3 | a1 | 1 | s2 5 | a2 | 2 | s3 6 | a3 | 3 | s1 7 | a1 | 1 | s3 8 | a2 | 2 | s2 ... Everytime we insert new record in table2, table3 must have such kind of results: table3: ------- id | local_idx (from table2) | local_idx (from table1) ------------------------------------------------------ 1 | 1 | 1 2 | 2 | 1 3 | 1 | 25 4 | 2 | 14 5 | 3 | 1 6 | 1 | 14 7 | 2 | 25 ... For example, when we insert (in table2) group a3 with local_idx 3 and subject s2 (which local_idx's 14) then result must be: 8 | 3 | 14
Triggers are used to give the ristrictions in performing applications example: A bank wants to stop the transaction on sunday , So this can be done in database using triggers.