Database Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesDatabase Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old April 26th, 2002, 04:21 AM
stuie stuie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 38 stuie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 52 sec
Reputation Power: 7
database design

i dont really know how to explain this, but all you fellas are smart so you should be able to help me out.

im creating a car related site that will have category listings that will items within the categories. im wanting to be able to add categories later on using PHP as a frontend. for example, i might want to have an engine category, with sub items like pistons, cylinder heads, engine blocks.

im currently thinking that i will have a table for each category, seeing that i wont have any idea of how many fields will be in each category.

the thing is, how can i list the categories if they each occupy a table?

i was wondering if anyone had any examples of this sort of thing that i could have a look at? i know that this probably doesnt make much sense.

any help is appreciated.

cheers

Reply With Quote
  #2  
Old April 26th, 2002, 04:24 AM
stuie stuie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 38 stuie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 52 sec
Reputation Power: 7
forget to add...

i forgot to say that my current idea is to have a table for each category, and another table to keep the names of the category tables.

so long...

Reply With Quote
  #3  
Old April 26th, 2002, 08:26 AM
q2ip q2ip is offline
Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: South Africa
Posts: 7 q2ip User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to q2ip
Hey....
I have an idea.. first off, you only need two tables: categories and items. The categories table will hold all of the categories,sub categories, etc...and it can be as deep (i.e. hierarchical) as you like. Here's how youd do the categories table:

create table categories
(
catId int auto_increment not null,
catName varchar(50) not null,
parentId int not null default 0,
primary key(catId),
unique id(catId)
);

notice the parentId field? By default its zero, which would mean any categories with 0 are parent categories... For sub categories you just place the id of the parent category into the sub cats parentId field... youd create a function to list the categories, something like this:

function showCats($parentId = 0)
{
// database conn stuff here
$result = mysql_query("select catName from categories where parentId = $parentId";

while($row = mysql_query($result))
{
// First show the category
echo $row["catName"] . "<br>";

// Now call this function with the parent id to get
// all of its sub cats
showCats($row["parentId"];
}
}

do you understand how that works? its a recurring function i.e. it calls itself... that way you can add some code to display items... but im sure you get my point

Reply With Quote
  #4  
Old April 26th, 2002, 08:36 AM
stuie stuie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 38 stuie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 52 sec
Reputation Power: 7
Unhappy can i complicate this further?

sounds good, although... i want to assign a persons name to a particular item in a category... for example this person (id437) is an expert at this category... and have the ability for more than one person per item.

for example

under category 'engine'.. you would have an item, 'pistons'... ok i want to assign some people to pistons to say that they are piston experts... does that make sense?

you sound like you know what your on about... just wondering if you could help me out?

cheers mate!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesDatabase Development > database design


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway