Advertisement

11.24.2008 at 07:28PM PST, ID: 23932922
[x]
Attachment Details

Table Definition and SQL Select statement help for new table definition.

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.3
Zone:

MySQL Server

I'm not sure the best way to ask my question, so it may be a bit wordy.  I'm trying to come up with a decent table structure that will grow with my application...

I have a database with a table named information that contains 2 columns, info_label and info_value.  Essentially what is stored here are name/value pairs.

In another table, I would like to associate the info_label to a row in the category table, which has a cat_label and a cat_position column, in addition to the info_label column (used for joining).  By joining these tables, I should be able to list all the rows in the information table in the order defined by the cat_position column in the category table.

I can do this ok, but the problem I am running into now is with nested categories...

Picture the scenario as an app to monitor certain OS level and installed software settings.  the Category could be "Network Information" and I could list all my rows in the information table related to the Network Information settings on my server under this heading.  This much I can do.

But, now I have multiple instances of something running on this server that I want to list configuration information for, like a Database, or an application server. For an application server, I want a heading (category) of "Application Server Settings"  and then I want a sub-heading that is an application server's name and under that I would list all the specific name/value pairs for that application server.  Then there would be another application server name with the settings for that server, etc... until all the application servers were listed.

I'm trying to determine what a good table structure would look like for this.  The key is, I'm trying not to limit myself by having the solution only work if there are X number of categories.  I'd like it to work for any number of categories without having to rewrite code, add columns, etc...

I was thinking of something like

DROP TABLE IF EXISTS `testing_pos`;
CREATE TABLE `testing_pos` (
  `cat_id` smallint(6) NOT NULL default '0',
  `parent_cat_id` smallint(6) NULL default NULL,
  `cat_pos` smallint(6) NOT NULL default '0',
  `aud_ts` timestamp NOT NULL default CURRENT_TIMESTAMP,
  PRIMARY KEY  (`cat_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


Where a cat_id would be tied back up to  a parent category if there is one...  (and that cat_parent_id could be tied back to it's own cat_parent_id, etc...) but I can't figure out how to write the SQL Select statement that will dynamically order things the right way, based on cat_id & cat_position.


Please, if there is a better way to structure this information, feel free to tell me. I am writing this program and have full control over table structures, so I'm happy to make structural changes now, vs. 6 months from now when I have a program being used across our company.

 
Author Comment by Bbouch:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Accepted Solution by routinet:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
20081119-EE-VQP-45 - Hierarchy / EE_QW_2_20070628