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?

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)

: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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.