Hi all,
Am somewhat new to SQL (although have been programming for 2 years), however hopefully someone can assist with a question or two I have (or point me in the right direction resource wise) in creating table relationships.
1. I have, as an example, the following 4 tables:
Purchase
purchaseID (PK)
Rel: Many to 1 with Budget
Budget
purchaseID (PK)
speciesID (PK/FK)
Rel: Many to 1 with Species
Rel: One to Many with Purchase
Species
speciesID
speciesType
Rel: Has a 1 to Many with Breed
Rel: Has a 1 to Many with Budget
Breed
breedID (PK)
breedType
Rel: Has a Many to 1 with Species
Typically the data in 'Species' and 'Breed' are primarily for reference, and Budget and Purchase are used to record Purchases of Species being of a Breed type. The 'Breed' table is like a subclass of 'Species', with Species Having numerous types with each having numerous Breed types as well.
Now If I want to store the Breed Type from a selected Species for a Purchase (which is selected from a drop down list directly referencing the Brreed Table) do I:
(a). Create a field in the 'Purchase' table and simply populate it from the user selection.
(b). Created a relationship in the DB between the Purchase Table and the Breed Table so as to inherit the breedID value as a Foreign Key which would map, on being queried, the the BreedType.
(a) doesnt seem right as It feels like I'm replicating data, yet if I applied (b) to all tables in the DB they would all be linked! How far deep in relationship, going through other tables, do you go to retrieve a value before you just relate two tables directly?
TIA