To explain how tables can be related to one another lets consider an example of a common process: checking books out of a library.
First of all, you have the books, so a table to hold the books
tblBooks
-pkBookID primary key, autonumber
-txtTitle
-txtAuthorFirstName
-txtAuthorLastName
Here are a couple example records
pkBookID|txtTitle|fkAuthorID
1|The Adventures of Sherlock Holmes|Arthur|Doyle
2|Harry Potter and the Goblet of Fire|J|Rowling
I use naming conventions for fields in my tables that help me identify the fields more efficiently. I always have an autonumber primary key field. I always use the prefix pk and the suffix ID so that I know it is a key field and it is primary. I use the key fields to establish relationships. The primary key field basically gives the record a unique identifier.
A txt prefix designates that the field is a text field. I usually use dte as the prefix for a date field.
In tblBooks you see the two author fields. Since authors can write several books (one author-many books), it would be a time savings not to have to type the same author's name for all of the books they have written. There is also the problem of spelling errors. It would be time consuming to go through each record and find if an author's name is spelled correctly or not. To handle this more efficiently, I would rather type the author's name only once and relate it to the books they have written. So to do that I would create a table with just the author names
tblAuthors
-pkAuthorID primary key, autonumber
-txtAuthorFirstName
-txtAuthorLastName
Let's show some example author records in the tblAuthors
pkAuthorID|txtAuthorFirstName|txtAuthorLastName
1|J|Rowling
2|Arthur|Doyle
3|William|Shakespeare
You can also include other details about the author in this table if you wanted to i.e. date of birth, date of death etc.
Now going back to our tblBooks, I want to replace the two author fields with a reference (or a relation) to the tblAuthors I just created. To do this, I use a foreign key field that relates back to the primary key field of the author table. A foreign key field must be the same data type as the primary key field it relates back to. An autonumber field is equivalent to a long number field. So the tblBooks, now looks like this
tblBooks
-pkBookID primary key, autonumber
-txtTitle
-fkAuthorID foreign key to tblAuthors
Here are a couple example records
pkBookID|txtTitle|fkAuthorID
1|The Adventures of Sherlock Holmes|2
2|Harry Potter and the Goblet of Fire|1
As you can see, the first record in the tblBooks (pkBookID=1) is entitled The Adventures of Sherlock Holmes and it was written by the author whose whose foreign key=2 which corresponds to the primary key=2 in the author table or Arthur Doyle. Having this foreign key relating back to another record in another table establishes the relationship between the records in the two tables.
Now continuing our example, the library want to track any books its patron checks out, so we need a patron table
tblPatron
-pkPatronID primary key, autonumber
-txtPatronFirstName
-txtPatronLastName
-longPatronCardNo (long prefix designates a long number data type for the field)
Example records
pkPatronID|txtPatronFirstName|txtPatronLastName|longPatronCardNo
1|Joe|Public|39549943
2|Jane|Doe|94934040
Now a patron will check out any number of books (one patron-many books)
tblPatronBooks
-pkPatronBookID primary key, autonumber
-fkPatronID (foreign key relating back to tblPatron)
-fkBookID (foreing key relating back to tblBooks)
-dteCheckOut
Let's say Jane Doe checks out the Harry Potter book today, the record would look like this:
pkPatronBookID|fkPatronID|fkBookID|dteCheckOut
1|2|2|06/09/2009
Here is a link to at
tutorial that goes through the basics of Access hopefully it will explain things better than I.
Also I still a little unclear as to how I can save the inputted data each day and start again the next !,Sorry to sound so vague !!!!!
You would use forms to enter your data. When you enter a record it is stored in the database until you delete it. In simple terms, you would enter a record for the train leaving its desitination, another record for when it arrives at your station, another record when it departs your station and a record for when it arrives at its final destination (if you want to track a train through its entire route). These records would be related to the route in the structure I presented yesterday.