I have the following tables:
Table 1
IDProduct | Price
--------- | -----
1 | $500
2 | $100
Table 2
IDProduct | Desc
--------- | ------
1 | Desc 1
1 | Desc 2
1 | Desc 3
What I want to do is only accept a total of 3 register with the same Id in Table 2, like the above example, if I try to register another row with Id 1 an error must happen or something, is this possible to do in Sql Server or I need to handle this outside sql (js, php, c#, etc.)
In other simple words I want that my Table 1 only accepts a total of 3 rows with the same IdProduct, maybe I have to try it with a trigger? an stored procedure with if, else?