I’m pretty new to databases and SQL, but as a homework I have to create a database for a homeless shelter.
This is the relational model.
My problem is the following: I want to create a trigger that won’t allow me to insert a new entry of a person that already exists in Persoane (so inserting into Cazare will fail) if the previous Gravitate abatere (if there is one) from Observatii is above 6 and it hasn’t passed x months from last accommodation.
The idea behind this logic is to not let someone who has done a bad thing rated above 6 in the shelter for x months. This being the first database course that i have to take in my uni we don’t learn triggers yet so i have no idea on how to do it. Any help is appreciated.

![How to create a trigger in Oracle SQL using values from another table? [closed] How to create a trigger in Oracle SQL using values from another table? [closed]](https://www.staccatocommunications.com/wp-content/uploads/2024/01/how-to-create-a-trigger-in-oracle-sql-using-values-from-another-table-closed_1009.jpg)


