What principles should I follow when entering data into a complex relational database?
A foreign key relates to the primary key of another table. When the record with the foreign is entered, the corresponding record with that primary key must be present. Therefore you must always start by inserting in the tables on the 1-side of the relation (the master or parent or primary key table). Then only you can enter a record on the n-side of the relation (into the detail or child or foreign key table).
Order: 1. Entry, 2. Keyword, 3. Keyword_Priority.
If a table has several foreign keys, then the related records in all the other tables with the corresponding primary keys must be entered first. For instance, before entering a record into SenseRestricted...
, the corresponding records in Sense
and in Reading
must have been inserted.
Some general advice. In the image, I guess Keyword_Priority is dependent on Keyword which is dependent on Entry. You, therefore, need to start with Entry, then Keyword, etc.
From a modelling perspective, something is something regardless of where in the model you use it. The entry looks pretty decent:
CREATE TABLE entry
( EntryId ... NOT NULL PRIMARY KEY
, ...
);
For keyword, something like:
CREATE TABLE keyword
( KeywordId ... NOT NULL PRIMARY KEY
, ...
, EntryId ... REFERENCES entry (EntryId)
)
I.e. don't use Id, it is too vague. The attribute is an id of something in particular. Also, note how that the attribute EntryId is named similar as in entry.
I won't delve into the question of surrogate keys since I believe there are limitations in ms-access (at least it used to be that way), that prevents composite foreign keys.