Relational databases will enforce referential integrity - assuming you've set up the foreign keys correctly.
1) This will ensure key1
and key2
actually point to rows in the primary tables.
2) If you also want to ensure only one row with a particular pair of foreign keys can exist in the link table, you will have to add a unique constraint in the database on those columns.
If you are using the pair of foreign keys as your link table primary key, you should be fine.