Click here to Skip to main content
16,018,916 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Pls some one tell that
how to creat parent and child relationship in single one table itself in sql server

pls some one tell.....
Posted
Comments
Richard C Bishop 12-Sep-13 14:19pm    
I must say, I have no idea what you are talking about.

Please someone chime in if sense can be made.

1 solution

Yes you can. you can create a parentid fields and make that foreign key to your Id field. In that way you can make parent child relationship in single table.
 
Share this answer
 
Comments
chander rani 12-Sep-13 14:41pm    
yes like in one category table there is 2 categories cat1 and cat2, and under the cat1 there is subcat1 and subcat2 and like this also for cat2, under the cat2 there is subcat1 and subcat2.
this is binary format to store the data in single table, we have to implement the parent and
child relationship in one single table itself.
[no name] 13-Sep-13 1:10am    
Here the table will look like.]
Catergoty
============
CategoryID
ParentCategoryID
Category Name

Here Parent Category will be foreign key to the same table categoryid field.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900