0

I have been trying to learn this database thing for the last 3 months without much success , its understanding the structure that puzzles me the most

say for example i want a page listing all types of fruit

oranges
apples
bananas
grapes

then i would want another page listing just apples which would show all names available in that gategory

example
grannys smiths, pink lady, golden delicious etc etc (names of apples)

and then another page just for granny smiths and so on.

how would i structure the tables in a database to do this?

3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by VioletSite
0

well, depending on the situation, there are many ways you could do it, one would be:

tblFruit
fruitID int
fruitName varchar(25)

tblFruitSub1
Sub1ID int
fruitID int //foreign key to tblFruit.fruitID
Name varchar(25)

tblFruitSub2
Sub2ID int
Sub1ID int //foreign key to tblFruitSub1.Sub1ID
Name varchar(25)

0

:idea: Here's how I would do this:

tblFruit_Names
fruit_NameID int//Optional (depends on further processing needs)
fruit_Name varchar(25)
Fruit_TypeID int//foreign key to tblFruit_Types.fruitID

tblFruit_Types
fruit_TypeID int//foreign key to tblFruit_Names.fruitID
fruit_Type_Name varchar(25)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.