I looked through and found some similar questions, but they were for SQL Server.
Here is a small structured database that I created to show you the relationships that I want to model. It is basically quite simple, each year has 12 periods, and the example of a period-year cannot happen twice (the period of the 9th year of 2012 cannot happen more than once).

Therefore, I thought that the best way to model this would be to have a table period with only one field with values from 1-12, a tabular year following the same logic (2011,2012 ...), and since this is an N-to- N, I created a period_by_year table that joins them to use rpt_maintenance_kpi. Now the tricky part is that in order for each combination to be unique, I made the period_no and year_no part of the composite primary key. In my opinion, this solves the problem elegantly, but then I went in cycles on how to refer to this composite primary key from rpt_maintenance_kpi (or any other table, for that matter). I tried to make two connections, but this does not seem to work (creates a second rpt_maintenance_kpi table, and I believe that this will not do what I want to do).
So how can I handle a foreign key for a composite primary key?
Thank you very much in advance.
source share