在图书馆管理系统中,如何保持学生在取书过程中所做的事务.我有两个表学生和一个到多个relationship...Now的表学生,如果有学生发行5本不同的书,那么这些信息如何存储在数据库中?请帮帮忙
发布于 2016-12-26 16:28:56
一个学生可以借零或更多的书,一本书是由零个或更多的学生借来的。这是一本关于许多关系的教科书,它需要第三张表格。
因此,您需要一个具有如下结构的Borrow表
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
)
现在,您可以注册一个借阅事件,并跟踪有关该事件本身的书籍和其他历史信息的内容。
https://stackoverflow.com/questions/41333703
复制相似问题