I have a Categories table and Items table like these:
Categories
CategoryID CategoryName CategoryLevel OrdinalNumber 1 All 0 1 2 iOS 1 2 3 Android 1 5 4 Sub iOS 1 2 3 5 Sub Andoid 1 2 6 6 Others 1 8 7 Sub Andoid 2 2 7 8 Sub iOS 2 2 4
Items
ItemID ItemName CategoryID 1 iPhone 5 4 2 Motorola Droid 5 3 iPad 2 8 4 Samsung S1 7 5 iPhone 4 4 6 iPad Air 8 7 Samsung S3 7 8 Dell Laptop 6
As you can see, they can be join by CategoryID. The Categories table, if sorted by OrdinalNumber and CategoryLevel, has tree-view display:
All
iOS
Sub iOS 1
Sub iOS 2
Android
Sub Andoid 1
Sub Andoid 2
Others