插入数据发行 [英] Inserting Data Issue

查看:80
本文介绍了插入数据发行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个名为book的产品,具有很多类别.我已经使用
创建了数据库 1)带有bookid(pri.key),categoryid(frn.key),描述的书详细信息
2)类别为categoryid(pri.key),类别名称的类别.

问题是我有一本书有多个类别
如何使用asp.net和c#存储在数据库中?

解决方案

您必须分别存储category_id和bookid.因此bookDetails表将包含有关书籍的信息.
由于书籍和类别之间存在一对多的映射关系,因此以bookid,categoryid作为列来创建名为BookCategories的新表.换句话说,数据库中的一本书可以属于多个类别,同样,一个类别可以适用于许多书籍?

tblbook
BookID(主键)
书名

tblCategory
CategoryID(主键)
CategoryName

tblBook_Category
BookCategoryID(主键)
BookID
CategoryID




您将所有书籍都放在tblBook中,所有可能的类别都放在tblcateogry中,并将这些书籍绑定到第三张表tblbook_category


中的类别

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#?

解决方案

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.


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


这篇关于插入数据发行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆