Say I have a three level category (for say, index of study courses) like this:
B.A. => Has child categories like Social Science, Accounting and so on
Then these child categories have children of their on, say : Insurance, Funding and so on.
Now, if I am in the grandchild category, and say I need to present a link that contains both the father and the grandfather, what is the most efficient way to do this?
The way I have it now, I have a property named "fatherId", and so when I need the father or/and the grandfather, I get them from this id (get categoryById function).
Say I have a three level category (for say, index of study courses) like this:
B.A. => Has child categories like Social Science, Accounting and so on
Then these child categories have children of their on, say : Insurance, Funding and so on.
Now, if I am in the grandchild category, and say I need to present a link that contains both the father and the grandfather, what is the most efficient way to do this?
The way I have it now, I have a property named "fatherId", and so when I need the father or/and the grandfather, I get them from this id (get categoryById function).
Is there a better way?
Thanks! Yonatan
Your design is fine, you can also provide a property for a grandChilde witch represents its father, also the father itself has a prperty tha represents his father witch is the grandfather for the first node. something like this:
public class Node
{
public int ID { get; set; }
public Node Parent
{
get
{
return SomeClass.GetCategoryById(this.ID);
}
}
}
Now, if I am in the grandchild category, and say I need to present a link that contains both the father and the grandfather, what is the most efficient way to do this?
The best way to handle this is
Table shouldBe
Category : Table Name
Columns
ID :Primary key
CategoryID
Description
ParenetID : Foreign Key of Category table's ID column
So if ParentID is null then its main paranet data other wise it contains its any of the parenet id. So in this way you can handle n number of child parent relation ship
Let me know still you have any questions.
My Tech Blogs MCPD Enterprise and Web Application
MCTS Web, Window and Enterprise Application
yonatan1082
Member
42 Points
71 Posts
Designing a three level category item
Apr 18, 2012 06:34 AM|LINK
Hi Everyone.
Say I have a three level category (for say, index of study courses) like this:
B.A. => Has child categories like Social Science, Accounting and so on
Then these child categories have children of their on, say : Insurance, Funding and so on.
Now, if I am in the grandchild category, and say I need to present a link that contains both the father and the grandfather, what is the most efficient way to do this?
The way I have it now, I have a property named "fatherId", and so when I need the father or/and the grandfather, I get them from this id (get categoryById function).
Is there a better way?
Thanks! Yonatan
tusharrs
Contributor
3230 Points
668 Posts
Re: Designing a three level category item
Apr 18, 2012 06:45 AM|LINK
Hi,
Please refer to this link
http://aspnetajax.componentart.com/control-specific/datagrid/features/hierarchical_display/WebForm1.aspx
OR
you can build the same grid using gridview and javascript in asp.net
( Mark as Answer if it helps you out )
View my Blog
Amin.Mirzapo...
Member
546 Points
98 Posts
Re: Designing a three level category item
Apr 18, 2012 07:00 AM|LINK
Your design is fine, you can also provide a property for a grandChilde witch represents its father, also the father itself has a prperty tha represents his father witch is the grandfather for the first node. something like this:
public class Node { public int ID { get; set; } public Node Parent { get { return SomeClass.GetCategoryById(this.ID); } } }yonatan1082
Member
42 Points
71 Posts
Re: Designing a three level category item
Apr 18, 2012 07:09 AM|LINK
Thanks
But this question is about architecture.
Say you have the same entity/class called "CategoryItem".
You have to display a link of this category in the following manner :
<a href="\Cat1Name\Cat2Name\Cat3Name">Cat3NameOfLink</a>
In the Category Item currently there is only the father id, and you do not know in which level you are.
amitpatel.it
Star
8070 Points
1880 Posts
Re: Designing a three level category item
Apr 18, 2012 07:20 AM|LINK
The best way to handle this is
Table shouldBe
Category : Table Name
Columns
ID :Primary key
CategoryID
Description
ParenetID : Foreign Key of Category table's ID column
So if ParentID is null then its main paranet data other wise it contains its any of the parenet id. So in this way you can handle n number of child parent relation ship
Let me know still you have any questions.
MCPD Enterprise and Web Application
MCTS Web, Window and Enterprise Application