数据库准备(SQL server)
books表(图书表)
USE [booksys]
GO
/****** Object: Table [dbo].[books] Script Date: 2023/8/10 11:02:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[books](
[book_id] [int] NOT NULL,
[publisher] [nvarchar](100) NULL,
[book_name] [nvarchar](100) NULL,
[isbn] [nvarchar](20) NULL,
[author] [nvarchar](100) NULL,
[category] [nvarchar](50) NULL,
[price] [decimal](10, 2) NULL,
[page_count] [int] NULL,
[status] [nvarchar](20) NULL,
PRIMARY KEY CLUSTERED
(
[book_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
表数据
users表(用户表)
USE [booksys]
GO
/****** Object: Table [dbo].[users] Script Date: 2023/8/10 11:09:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[users](
[user_id] [int] NOT NULL,
[user_name] [nvarchar](50) NOT NULL,
[user_pwd] [nvarchar](50) NULL,
CONSTRAINT [PK_users] PRIMARY KEY CLUSTERED
(
[user_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
表数据
publishers表(出版社表)
USE [booksys]
GO
/****** Object: Table [dbo].[publishers] Script Date: 2023/8/10 11:11:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[publishers](
[publisher_id] [int] NOT NULL,
[publisher_name] [nvarchar](100) NULL,
[address] [nvarchar](200) NULL,
[contact_person] [nvarchar](100) NULL,
[phone_number] [nvarchar](20) NULL,
PRIMARY KEY CLUSTERED
(
[publisher_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
表数据
categories表(书本类型表)
USE [booksys]
GO
/****** Object: Table [dbo].[categories] Script Date: 2023/8/10 11:12:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[categories](
[category_id] [int] NOT NULL,
[category_name] [nvarchar](50) NULL,
[description] [nvarchar](100) NULL,
PRIMARY KEY CLUSTERED
(
[category_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
表数据
records表(借阅记录表)
USE [booksys]
GO
/****** Object: Table [dbo].[records] Script Date: 2023/8/10 11:15:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[records](
[record_id] [int] IDENTITY(1,1) NOT NULL,
[book_id] [int] NULL,
[user_name] [nvarchar](50) NULL,
[book_name] [nvarchar](100) NULL,
[borrow_date] [datetime] NULL,
[due_date] [datetime] NULL,
[return_date] [date] NULL,
[renew_count] [int] NULL,
PRIMARY KEY CLUSTERED
(
[record_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[records] ADD DEFAULT (getdate()) FOR [borrow_date]
GO
ALTER TABLE [dbo].[records] ADD DEFAULT ((0)) FOR [renew_count]
GO
ALTER TABLE [dbo].[records] WITH CHECK ADD FOREIGN KEY([book_id])
REFERENCES [dbo].[books] ([book_id])
GO
ALTER TABLE [dbo].[records] WITH CHECK ADD FOREIGN KEY([user_name])
REFERENCES [dbo].[users] ([user_name])
GO
表数据
所有表