Hi,
I am tapping in my far too old knowledge of SQL and databases and… I’m stuck. I am missing something, and it “doesn’t click” in my brain…
So, I have few exercices, let’s say Exo_1, Exo_2, Exo_3, etc… with a description, some objectives, all good.
I have let’s cal theme categeories, in 3 layers, ie
Cat 1
Sub_Cat 1.1
Sub_Sub_Cat 1.1.1
Sub_Sub_Cat 1.1.2
Sub_Cat 1.2
Sub_Sub_Cat 1.2.1
Sub_Sub_Cat 1.2.2
Sub_Sub_Cat 1.2.3
Cat 2
Sub_Cat 2.1
Sub_Sub_Cat 2.1.1
Sub_Sub_Cat 2.1.2
Sub_Cat 2.2
Sub_Sub_Cat 2.2.1
Sub_Sub_Cat 2.2.2
Sub_Sub_Cat 2.2.3
Etc…
I want to be able to “add” mutliple categories to one give exercice
Ex. Exo_1 can have :
Cat 1 → Sub_Cat 1.1 → Sub_Sub_Cat 1.1.1
Cat 1 → Sub_Cat 1.1 → Sub_Sub_Cat 1.2.1
Cat 2 → Sub_Cat 2.2 → Sub_Sub_Cat 2.2.3
I created tables for :
Exercices
Categories
Sub_Cat
Sub_Sub_Cat
(i still have to ensure the correct Sub_Cat can be selected, ie. if Cat 1.2 is selected, I shouldn’t be able to pick a Sub_Sub_Cat 1.1.1 for exemple, but that will be the next step)
So, now, how to I link these ?
Cause I don’t know which exercice will have which categories, that’s why I’m going through all of this : I want to be able to add the categories “on the fly” to my exercices and then, I’ll be able to run reports per category for exemple (which will give me the exercices which fall into that category (and potentially other categories as well).
In other words :
- 1 exercice can have multiple categories
- 1 category will of course be linked to multiple exerices
I can’t get clarity if I shlould have the Cat, Sub_Cat and Sub_Sub_Cat Primary Key in the Exercice table, or the other way around, i.e. the Exercice Primary Key in the Cat, Sub_Cat and Sub_Sub_Cat table…
Any support on how to do this will be welcome