i have four tables:
Table 1.)info_firm
------------------------
id | name | class_id |
------------------------
1 | CNN | 1000 |
2 | MTV | 1000 |
3 | Radio1 | 1001 |
FK class_id references info_class(id)
Table 2.)info_class
-------------------
id | name |
-------------------
1000 | television |
1001 | radio |
Table 3.)info_param
-------------------------------------------------------
id | parameter | class_id | type
-------------------------------------------------------
30 | position on market | 1000 | 1
31 | awards | 1000 | 3
32 | hours p. day of broadcasting | 1000 | 2
33 | frequency | 1001 | 2
FK class_id ---> info_class(id)
This table stores parameters for each group(class) of firms
Each parameter may be int or real or string.
type 1 means: value of parameter is integer
type 2 means: value of parameter is float
type 3 means: value of parameter is string
Table 4.)info_stat
------------------------------------------------------------
id | firm_id | param_id | val_int | val_real | val_string
------------------------------------------------------------
50 | 1 | 30 | 1 | NULL | NULL
51 | 1 | 31 | NULL | NULL |bestTV
52 | 1 | 32 | NULL | 23.5 |NULL
53 | 2 | 30 | 2 | NULL | NULL
54 | 2 | 31 | NULL | NULL | none
55 | 2 | 32 | NULL | 22.5 | NULL
56 | 3 | 33 | NULL | 156.6 | NULL
This table stores values for given parameters
Only one of the fields val_int, val_real and val_string is actual, according to value of info_param.type (e.g. if info_param.type is 1, we must look at val_int)
FK firm_id ----> info_firm(id)
FK param_id ----> info_param(id)
_________________________________________
I want a select giving this results:
for given info_class.name (for example television)
result of select:
---------------------------------------------------------
name | pos. on. market | awards | h.p.d broadcast.
---------------------------------------------------------
CNN | 1 | bestTV | 23.5
MTV | 2 | none | 22.5
or result of select for class.name radio
-------------------
name | frequency
-------------------
Radio1 | 156.6
Which means, for given class i want to get all firm names included in that class, and for each firm i want to get all
parameters defined for given class in table info_param with values from info_stat. Is it possible?
Table 1.)info_firm
------------------------
id | name | class_id |
------------------------
1 | CNN | 1000 |
2 | MTV | 1000 |
3 | Radio1 | 1001 |
FK class_id references info_class(id)
Table 2.)info_class
-------------------
id | name |
-------------------
1000 | television |
1001 | radio |
Table 3.)info_param
-------------------------------------------------------
id | parameter | class_id | type
-------------------------------------------------------
30 | position on market | 1000 | 1
31 | awards | 1000 | 3
32 | hours p. day of broadcasting | 1000 | 2
33 | frequency | 1001 | 2
FK class_id ---> info_class(id)
This table stores parameters for each group(class) of firms
Each parameter may be int or real or string.
type 1 means: value of parameter is integer
type 2 means: value of parameter is float
type 3 means: value of parameter is string
Table 4.)info_stat
------------------------------------------------------------
id | firm_id | param_id | val_int | val_real | val_string
------------------------------------------------------------
50 | 1 | 30 | 1 | NULL | NULL
51 | 1 | 31 | NULL | NULL |bestTV
52 | 1 | 32 | NULL | 23.5 |NULL
53 | 2 | 30 | 2 | NULL | NULL
54 | 2 | 31 | NULL | NULL | none
55 | 2 | 32 | NULL | 22.5 | NULL
56 | 3 | 33 | NULL | 156.6 | NULL
This table stores values for given parameters
Only one of the fields val_int, val_real and val_string is actual, according to value of info_param.type (e.g. if info_param.type is 1, we must look at val_int)
FK firm_id ----> info_firm(id)
FK param_id ----> info_param(id)
_________________________________________
I want a select giving this results:
for given info_class.name (for example television)
result of select:
---------------------------------------------------------
name | pos. on. market | awards | h.p.d broadcast.
---------------------------------------------------------
CNN | 1 | bestTV | 23.5
MTV | 2 | none | 22.5
or result of select for class.name radio
-------------------
name | frequency
-------------------
Radio1 | 156.6
Which means, for given class i want to get all firm names included in that class, and for each firm i want to get all
parameters defined for given class in table info_param with values from info_stat. Is it possible?