![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
| | | +--- Bolts | +--- Bolts | +---- |
#2
| |||
| |||
|
|
| | | | +-Bolts | +-Bolts | +-BBs |
|
Hi, I'm looking for advice on how to store a components and parts type schema in a database. Take the following as an example: 1 x Engine requires: - 5 bolts (base part) - 6 nuts (base part) - 3 washers (base part) - 4 fans (component) 1 x Fan requires: - 3 bolts (base part) - 2 washers (base part) - 2 ball bearing sets (component) 1 x Ball Bearing Set requires: - 10 ball bearings (base part) - 3 bolts (base part) - 2 washers (base part) There are two distinct types here: components (engine, fan, BB set) and base parts (bolts, nuts, washers, ball bearings). I want to be able to store this information in the most efficient way possible in a database. The front-end using the database will need to be able to run queries that say things like 'get me the complete diarchal part list for an engine' or 'get me the complete diarchal part list for a fan'. At the moment I store this information in an array and recurse through it as many times as is needed to get the part lists. However, I now need to allow the users to maintain the components & parts data. I recently came across a technique called Modified Preorder Tree Traversal that I used to store a tree like structure and I was wondering if there is another technique that I could use here. MPTT won't work in this case because it isn't really a tree structure i.e. Engine, Fan and Ball Bearing Set are all components as such and reside at the same level in the tree, which each having children that point to each other. Engine +---- Fan +---- BB Set | | | | | +--- Bolts | +--- Bolts | +---- Ball bearings Nuts | Washers | Bolts Washers | BB Sets ----+ Washers Fans ------+ Please excuse the cheap diagram! :-) One person I have spoken to suggests building another table that stores the list of components needed by a component e.g. Engine -> Fan, Ball Bearing Set. Then this could be queried first and the relevant records retrieved from the components table by the front-end, which could work with the data in memory, rather than recurse the database. However, I was wondering if there was a more elegant way to approach this. On a last note, in case it matters, I am using PHP4 & MySQL4. I hope I've given a decent enough explanation of what I am trying to do. Thanks for any help you can provide. Steve |
#3
| |||
| |||
|
|
Sorry, the diagram came out fairly poorly. Here's another go at it: Engine +-Fan +-BB Set | | | | | +-Bolts | +-Bolts | +-BBs Nuts | Washers | Bolts Washers | BB Sets-+ Washers Fans----+ "Stephen McNabb" <smcnabb (AT) vision_hatespam (DOT) com> wrote in message news:5smYb.54$AQ4.230158 (AT) newsfep2-win (DOT) server.ntli.net... Hi, I'm looking for advice on how to store a components and parts type schema in a database. Take the following as an example: 1 x Engine requires: - 5 bolts (base part) - 6 nuts (base part) - 3 washers (base part) - 4 fans (component) 1 x Fan requires: - 3 bolts (base part) - 2 washers (base part) - 2 ball bearing sets (component) 1 x Ball Bearing Set requires: - 10 ball bearings (base part) - 3 bolts (base part) - 2 washers (base part) There are two distinct types here: components (engine, fan, BB set) and base parts (bolts, nuts, washers, ball bearings). I want to be able to store this information in the most efficient way possible in a database. The front-end using the database will need to be able to run queries that say things like 'get me the complete diarchal part list for an engine' or 'get me the complete diarchal part list for a fan'. At the moment I store this information in an array and recurse through it as many times as is needed to get the part lists. However, I now need to allow the users to maintain the components & parts data. I recently came across a technique called Modified Preorder Tree Traversal that I used to store a tree like structure and I was wondering if there is another technique that I could use here. MPTT won't work in this case because it isn't really a tree structure i.e. Engine, Fan and Ball Bearing Set are all components as such and reside at the same level in the tree, which each having children that point to each other. Engine +---- Fan +---- BB Set | | | | | +--- Bolts | +--- Bolts | +---- Ball bearings Nuts | Washers | Bolts Washers | BB Sets ----+ Washers Fans ------+ Please excuse the cheap diagram! :-) One person I have spoken to suggests building another table that stores the list of components needed by a component e.g. Engine -> Fan, Ball Bearing Set. Then this could be queried first and the relevant records retrieved from the components table by the front-end, which could work with the data in memory, rather than recurse the database. However, I was wondering if there was a more elegant way to approach this. On a last note, in case it matters, I am using PHP4 & MySQL4. I hope I've given a decent enough explanation of what I am trying to do. Thanks for any help you can provide. Steve |
#4
| |||
| |||
|
|
Hi, I'm looking for advice on how to store a components and parts type schema in a database. Take the following as an example: 1 x Engine requires: - 5 bolts (base part) - 6 nuts (base part) - 3 washers (base part) - 4 fans (component) 1 x Fan requires: - 3 bolts (base part) - 2 washers (base part) - 2 ball bearing sets (component) 1 x Ball Bearing Set requires: - 10 ball bearings (base part) - 3 bolts (base part) - 2 washers (base part) There are two distinct types here: components (engine, fan, BB set) and base parts (bolts, nuts, washers, ball bearings). I want to be able to store this information in the most efficient way possible in a database. The front-end using the database will need to be able to run queries that say things like 'get me the complete diarchal part list for an engine' or 'get me the complete diarchal part list for a fan'. At the moment I store this information in an array and recurse through it as many times as is needed to get the part lists. However, I now need to allow the users to maintain the components & parts data. |
#5
| |||
| |||
|
|
Sorry, the diagram came out fairly poorly. Here's another go at it: Engine +-Fan +-BB Set | | | | | +-Bolts | +-Bolts | +-BBs Nuts | Washers | Bolts Washers | BB Sets-+ Washers Fans----+ "Stephen McNabb" <smcnabb (AT) vision_hatespam (DOT) com> wrote in message news:5smYb.54$AQ4.230158 (AT) newsfep2-win (DOT) server.ntli.net... Hi, I'm looking for advice on how to store a components and parts type schema in a database. Take the following as an example: 1 x Engine requires: - 5 bolts (base part) - 6 nuts (base part) - 3 washers (base part) - 4 fans (component) 1 x Fan requires: - 3 bolts (base part) - 2 washers (base part) - 2 ball bearing sets (component) 1 x Ball Bearing Set requires: - 10 ball bearings (base part) - 3 bolts (base part) - 2 washers (base part) There are two distinct types here: components (engine, fan, BB set) and base parts (bolts, nuts, washers, ball bearings). I want to be able to store this information in the most efficient way possible in a database. The front-end using the database will need to be able to run queries that say things like 'get me the complete diarchal part list for an engine' or 'get me the complete diarchal part list for a fan'. At the moment I store this information in an array and recurse through it as many times as is needed to get the part lists. However, I now need to allow the users to maintain the components & parts data. I recently came across a technique called Modified Preorder Tree Traversal that I used to store a tree like structure and I was wondering if there is another technique that I could use here. MPTT won't work in this case because it isn't really a tree structure i.e. Engine, Fan and Ball Bearing Set are all components as such and reside at the same level in the tree, which each having children that point to each other. Engine +---- Fan +---- BB Set | | | | | +--- Bolts | +--- Bolts | +---- Ball bearings Nuts | Washers | Bolts Washers | BB Sets ----+ Washers Fans ------+ Please excuse the cheap diagram! :-) One person I have spoken to suggests building another table that stores the list of components needed by a component e.g. Engine -> Fan, Ball Bearing Set. Then this could be queried first and the relevant records retrieved from the components table by the front-end, which could work with the data in memory, rather than recurse the database. However, I was wondering if there was a more elegant way to approach this. On a last note, in case it matters, I am using PHP4 & MySQL4. I hope I've given a decent enough explanation of what I am trying to do. Thanks for any help you can provide. Steve |
#6
| |||
| |||
|
|
I'm looking for advice on how to store a components and parts type schema in a database. |
#7
| |||
| |||
|
|
Hi, I'm looking for advice on how to store a components and parts type schema in a database. Take the following as an example: 1 x Engine requires: - 5 bolts (base part) - 6 nuts (base part) - 3 washers (base part) - 4 fans (component) 1 x Fan requires: - 3 bolts (base part) - 2 washers (base part) - 2 ball bearing sets (component) 1 x Ball Bearing Set requires: - 10 ball bearings (base part) - 3 bolts (base part) - 2 washers (base part) There are two distinct types here: components (engine, fan, BB set) and base parts (bolts, nuts, washers, ball bearings). I want to be able to store this information in the most efficient way possible in a database. The front-end using the database will need to be able to run queries that say things like 'get me the complete diarchal part list for an engine' or 'get me the complete diarchal part list for a fan'. At the moment I store this information in an array and recurse through it as many times as is needed to get the part lists. However, I now need to allow the users to maintain the components & parts data. I recently came across a technique called Modified Preorder Tree Traversal that I used to store a tree like structure and I was wondering if there is another technique that I could use here. MPTT won't work in this case because it isn't really a tree structure i.e. Engine, Fan and Ball Bearing Set are all components as such and reside at the same level in the tree, which each having children that point to each other. Engine +---- Fan +---- BB Set | | | | | +--- Bolts | +--- Bolts | +---- Ball bearings Nuts | Washers | Bolts Washers | BB Sets ----+ Washers Fans ------+ Please excuse the cheap diagram! :-) One person I have spoken to suggests building another table that stores the list of components needed by a component e.g. Engine -> Fan, Ball Bearing Set. Then this could be queried first and the relevant records retrieved from the components table by the front-end, which could work with the data in memory, rather than recurse the database. However, I was wondering if there was a more elegant way to approach this. On a last note, in case it matters, I am using PHP4 & MySQL4. I hope I've given a decent enough explanation of what I am trying to do. Thanks for any help you can provide. Steve |
#8
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |