在图书馆管理系统中,如何让学生在拿书时完成交易....我有两个表学生和书有一对多的关系...现在如果任何学生发行 5 本不同的书那么如何此信息存储在数据库中??请帮忙
最佳答案
一个Student可以借到零个或多个Books,一本书被零个或多个Students借走。这是教科书上的多对多关系,它需要第三张表
所以你需要一个结构如下的借用表
Create Table Borrows
(
IDBook int not null,
IDStudent int not null,
BorrowDate smalldatetime not null,
ReturnDate smalldatetime null,
BookStatusBefore nvarchar(32) not null,
BookStatusAfter nvarchar(32) not null
)
-- Primary key on IDBook+IDStudent....
ALTER TABLE Borrows ADD CONSTRAINT PK_Borrows PRIMARY KEY CLUSTERED
(
IDBook,
IDStudent
)
现在您可以注册一个借阅事件并跟踪一本书的下落以及有关该事件本身的其他历史信息。
关于c# - 如何在 C# .net 中管理图书馆管理系统中的学生和图书发行关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41333703/