C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

Database+ primary key foreigm key relationship


Posted Date: 01 Oct 2008      Posted By: radhika bista      Member Level: Gold     Points: 1   Responses: 1



hi,

how can i solve one to many relationship between catagory and product. here one catagory contain many products:

two alternatives:

use primary ley foeign keu relationship: use a field of catagiry id in for each peoduct.
or create a separate table for peoducts of a catagoey.

Thanks





Responses

Author: Ankit    01 Oct 2008Member Level: GoldRating: 4 out of 54 out of 54 out of 54 out of 5     Points: 6

See in scenarion, create a table for category say "Category" where you have the CategoryId as primary Key and Category Name. Now Create another table for product say "Product" where have fields like ProductId(Primary Key), CategoryId(Foreign Key from Category Table) and product Description or any relevant field.

Now in this scenarion, first you need to enter data for Category and when you enter any product then select category first and then enter product.

In this way you can delete any product from Product table, but you will be able to delete category only in a condition when all corresponding productss has deleted from the product table.



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : webapplication vedioplayer
Previous : Javascript calendar control
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use