I'm struggling with indexes, primary keys and foreign keys... And the need of having them all.
If I have two tables, both of them have an integer as a primary key.
The first table references through a FK to the second table's primary key.
- On both tables I have a primary key index on the ID column
- I created a FK constraint on the
table1.ref_field
referencing the PK of the second table (table2.id
) - and I added an index on
table1.ref_field
Is this the best way to organize these indexes, primary and foreign keys?