Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have the product called book with many categories.I have created database with
1)BookDetails with bookid(pri.key),categoryid(frn.key),description
2)category with categoryid(pri.key),categoryname.

The problem is i have a book with multiple categories
how to store in the database using asp.net and c#?
Posted

You have to store the category_id and bookid separetely. So the bookDetails table will contain information about book.
Since there is one to many mapping of book and category, create new table called BookCategories with bookid, categoryid as columns.
 
Share this answer
 
Comments
srinivas vadepally 31-Oct-11 9:15am    
hi prakash,
i have the category like tag in ask question of codeproject,the problem is how to extract categories and how to store in bookcategories table?
I belive, you are after many to many relation ship. in other words, a single book in your database can belongs to many categories and similarly a single category can be applicable to many books ?

tblbook
BookID (Primary Key)
BookName

tblCategory
CategoryID (Primary Key)
CategoryName

tblBook_Category
BookCategoryID (Primary Key)
BookID
CategoryID




You will have all your books in tblBook and the possible cateogies in tblcateogry and bind the books to the category in the third table tblbook_category
 
Share this answer
 
Comments
srinivas vadepally 31-Oct-11 10:07am    
hi bala,
i have the category like tag in ask question of codeproject,the problem is how to extract categories and how to store in bookcategories table?
Bala Selvanayagam 31-Oct-11 11:48am    
it depends on the User interface, how do you have books and the categiries implemented in the UI? and what do you have done so far ?

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