Is there a convient way to do a supertype/subtype heirarchy in mysql
and do queries on the supertype to return sets of subtypes?
For example, suppose I have a table with several types of military
hardware:
Table:
Id----Type--------Price
1.....Mig-15.....$20
1.....Mig-17.....$32
1.....Su-27......$80
1.....T-72........$20
What I'd like to be able to do is say:
SELECT FROM Table Where Type=Mig
instead of
SELECT FROM Table Where Type=Mig-15 or Type=Mig-17
Of course, we have to assume we have a type heirarchy:
Airplane
--Mig
----Mig-15
----Mig-17
--Su
----Su-27
Tank
--T
----T-72
What's the best way to represent this type heirarchy in the database
so as to require the minimum amount of queries to get a meaningful
result like all subtypes of Mig?
Thanks in advance,
Nick
and do queries on the supertype to return sets of subtypes?
For example, suppose I have a table with several types of military
hardware:
Table:
Id----Type--------Price
1.....Mig-15.....$20
1.....Mig-17.....$32
1.....Su-27......$80
1.....T-72........$20
What I'd like to be able to do is say:
SELECT FROM Table Where Type=Mig
instead of
SELECT FROM Table Where Type=Mig-15 or Type=Mig-17
Of course, we have to assume we have a type heirarchy:
Airplane
--Mig
----Mig-15
----Mig-17
--Su
----Su-27
Tank
--T
----T-72
What's the best way to represent this type heirarchy in the database
so as to require the minimum amount of queries to get a meaningful
result like all subtypes of Mig?
Thanks in advance,
Nick
Comment