![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi Everyone, I am playing with a db design at the moment and an idea has occurred to me that I would like to ask for advice / ideas on. The db is for storing product information in a 'dual heirarchy' way. What this means is that we have a normalised design with two 'paths' to a specific product (Category, SubCategory, Segment)(Manufacturer, Brand, Range). Each 'Product' has a unique id (the EAN code) as well as a unique technical key (autonumber), and has two foreign keys (range_id and segment_id). There are some standard fields that are applied to all products, such as Name, Weight, Height, Width, Depth, and so on. There are also different fields that would be great to be able to apply to certain categories of product, for example food products would benefit from having a 'Flavour' field, while books would benefit from an 'Author' and 'ISBN' field. What I was thinking of doing was to have a user defined list of appropriate fields and their data types, per category, so that appropriate information can be stored for each without having to build separate data tables per category. I have not tried something like this before and was wondering if anyone has given it a go? My initial thoughts run along the lines of having a table related to the category table where the field list would live. What I cannot seem to figure out is how to use SQL to return a list of products, with the user defined fields (and their values of course), for a given category so that each user defined field 'has a column of its own' so to speak. I think this should be possible but I just have no luck in wrapping my mind around a method to achieve this. Any advice or ideas would be greatly appreciated. The Frog |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Hi Everyone, snip What I was thinking of doing was to have a user defined list of appropriate fields and their data types, per category, so that appropriate information can be stored for each without having to build separate data tables per category. I have not tried something like this before and was wondering if anyone has given it a go? snip Any advice or ideas would be greatly appreciated. The Frog |
#5
| |||
| |||
|
|
On the right track Roger, but I was thinking a little simpler: tblRange: -range_id (pk) -range tblSegment: -segment_id (pk) -segment tblProduct: -product_id (pk) -ean * * * * * (unique) -product -range_id * *(fk) -segment_id (fk) tblFeature: -feature_id *(pk) -category_id (fk) * *(this is two levels 'above' range in the design) -feature In theory we can list all sorts of things here. My concern is in two parts: 1) How to effectively control the set of features that are available to an individual product without cascading a compound primary key down the line (so to speak). 2) How to provide a query that for any given category we would see a list of products with their 'heirarchical' fields as well as including - column by column - all the defined features (ie/ each feature as a separate field in the query). I need to be (if I am going to do this) provide the output query as pure SQL. It cannot be dependant on any VBA to work as the database must 'play nicely' with some of our other systems. If I have to carry a compound key then so be it, then use a joining table to simulate a many-many relationship. Does that clarify what I am trying to achieve a little better? I apologise for any lack of clarity in my earlier post. Cheers The Frog |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Roger, Thankyou for the SQL approach, it is exactly what i was looking for. What I will do is add code to the form that allows users to 'add a feature' to a category, and use VBA to generate the required SQL and save it as a query specific to each category. Depending on the number of records and features it might pay me to dump the results to a temp table. Either as a query or a temp table the 'play nice with other applications' part is taken care of. Clif, thats an extremely funny article on developing the 'Vision' application. I cant believe that anyone would be that stupid! Apparently ego and ambition outweighed ability and common sense. Sounds similar to my office........ Wait! Did I say that out loud????? Thanks guys. The Frog |
#8
| |||
| |||
|
#9
| |||
| |||
|
|
Hi imb, Thanks for the thought. I am guessing that the IT dept here wants to be able to get at the data without having to write any complex SQL themselves. If I can get the userform to craft the needed SQL and save it as a query in the back end file, then I am hoping that the IT dept can then access it any way they wish. Basically they dont want to play with a front end app at all and just want access to the data that is going to be the product of a lot of user input. The bigger picture is that the whole excercise is a data cleaning process to produce a table of products that will have 'trusted' definitions for their fields as well as the content of those fields. Each row of data, and each field in those rows needs to be manually approved. This is a big job indeed for the product lists we have, so I am trying to ease the pain with a little application that can take the source 'rough' data in, park it in temp tables, allow the users to process the data, and place the result into a structured back end that still leaves them some flexibility to alter things as the business changes and grows. It will eventually move to a master data system and the process will be discarded, but not until the existing lists are processed and cleaned to a trustworthy state. It is proving to be a surprisingly tedious and frustrating problem to solve, but by no means impossible. I really appreciate the feedback. Cheers The Frog |
#10
| |||
| |||
|
|
What I was thinking of doing was to have a user defined list of appropriate fields and their data types, per category, so that appropriate information can be stored for each without having to build separate data tables per category. |
![]() |
| Thread Tools | |
| Display Modes | |
| |