2022年图书管理系统[] 2.pdf
《2022年图书管理系统[] 2.pdf》由会员分享,可在线阅读,更多相关《2022年图书管理系统[] 2.pdf(15页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-创建数据库BlueSkyDB USE master GO IF EXISTS(SELECT * FROM sys.databases WHERE name=BlueSkyDB) DROP DATABASE BlueSkyDB GO CREATE DATABASE BlueSkyDB ON PRIMARY (NAME=BSPrimaryFile1, FILENAME=C:PrimaryFile1Data.mdf, SIZE=4MB, MAXSIZE=50MB, FILEGROWTH=1MB), FILEGROUP UserGroup1 (NAME=BSGroup1File1, FILENAME
2、=C:Group1File1Data.ndf, SIZE=2MB, MAXSIZE=50MB, FILEGROWTH=1MB), (NAME=BSGroup1File2, FILENAME=C:Group1File2Data.ndf, SIZE=2MB, MAXSIZE=50MB, FILEGROWTH=1MB), FILEGROUP UserGroup2 (NAME=BSGroup2File1, FILENAME=C:Group2File1Data.ndf, SIZE=1MB, MAXSIZE=50MB, FILEGROWTH=10%), FILEGROUP UserGroup3 (NAME
3、=BSGroup3File1, FILENAME=C:Group3File1Data.ndf, SIZE=1MB, MAXSIZE=50MB, FILEGROWTH=10%) LOG ON (NAME=BSLogFile1, FILENAME=C:LogFile1.ldf, SIZE=2MB, 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 15 页 - - - - - - - - - MAXSIZE=50MB, FILEGROWTH=1MB) GO -在 BlueSky
4、DB 中将文件组UserGroup1 配置为默认文件组。USE master GO ALTER DATABASE BlueSkyDB MODIFY FILEGROUP UserGroup1 DEFAULT GO -创建一个数据类型,用于存放图书价格数据。USE BlueSkyDB GO CREATE TYPE PriceDecimal FROM decimal(6,2) GO -在数据库BlueSkyDB 中创建表Cagegories,用于存放图书的类别信息。USE BlueSkyDB GO CREATE TABLE Categories (categoryCode nchar(4) PRIM
5、ARY KEY , categoryName nvarchar(50) NOT NULL ) GO -在数据库BlueSkyDB 中创建表Books,用于存放图书的信息。USE BlueSkyDB GO CREATE TABLE Books (bookID int IDENTITY(1,1) PRIMARY KEY , title nvarchar(50) NOT NULL, ISBN nchar(13) NOT NULL, author nvarchar(50), unitPrice PriceDecimal, categoryCode nchar(4) ) GO -在数据库BlueSkyD
6、B 中创建表Customers,用于存放顾客的信息。USE BlueSkyDB GO CREATE TABLE Customers (customerID int IDENTITY PRIMARY KEY , customerName nvarchar(20) NOT NULL, emailAddressnvarchar(50) NOT NULL, password nvarchar(50) NOT NULL ) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 15 页
7、- - - - - - - - - GO -在数据库BlueSkyDB 中创建表Orders,用于存放订单的信息。USE BlueSkyDB GO CREATE TABLE Orders (orderID int IDENTITY(1,1) PRIMARY KEY , orderDate datetime NOT NULL DEFAULT GETDATE(), shipDate datetime, customerID int NOT NULL ) GO -定义订单项目表OrderItems USE BlueSkyDB GO CREATE TABLE OrderItems (orderID i
8、nt NOT NULL, bookID int NOT NULL, quantity int NOT NULL DEFAULT 1, price PriceDecimal, total AS price*quantity, PRIMARY KEY(orderID,bookID) ) GO -定义评论表Comments USE BlueSkyDB GO CREATE TABLE Comments (commentID int IDENTITY PRIMARY KEY , userName nvarchar(50) NOT NULL, userEmail nvarchar(50) NOT NULL
9、, rating tinyint NOT NULL DEFAULT 5, comment nvarchar(200) NOT NULL, bookID int NOT NULL ) GO -创建表 ShoppingRecords 存放购物车的信息USE BlueSkyDB GO CREATE TABLE ShoppingRecords (recordID int IDENTITY PRIMARY KEY , cartID uniqueidentifier NOT NULL, quantity int NOT NULL, dateCreated datetime NOT NULL DEFAULT
10、 GETDATE(), bookID int NOT NULL 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 15 页 - - - - - - - - - ) GO -创建表 Books 与 Categories 之间的关系ALTER TABLE Books ADD CONSTRAINT Books_categoryID_fk FOREIGN KEY(categoryCode) REFERENCES Categories(categoryCode) GO -创建表 Or
11、ders 与 Customers 之间的关系ALTER TABLE Orders ADD CONSTRAINT Orders_customerID_fk FOREIGN KEY(customerID) REFERENCES Customers(customerID) GO -创建表 OrderItems 与 Orders 之间的关系ALTER TABLE OrderItems ADD CONSTRAINT OrderItems_orderID_fk FOREIGN KEY(orderID) REFERENCES Orders(orderID) GO -创建表 OrderItems 与 Book
12、s 之间的关系ALTER TABLE OrderItems ADD CONSTRAINT OrderItems_bookID_fk FOREIGN KEY(bookID) REFERENCES Books(bookID) GO -创建表 Comments 与 Books 之间的关系ALTER TABLE Comments ADD CONSTRAINT Comments_bookID_fk FOREIGN KEY(bookID) REFERENCES Books(bookID) GO -创建表 ShippingRecords 与 Books 之间的关系ALTER TABLE ShoppingRe
13、cords ADD CONSTRAINT ShoppingRecords_bookID_fk FOREIGN KEY(bookID) REFERENCES Books(bookID) GO -向 Categories 表导入数据USE BlueSkyDB GO INSERT INTO Categories V ALUES(CO01, 计算机 ) GO 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 15 页 - - - - - - - - - INSERT INTO Ca
14、tegories V ALUES(FI01, 小说 ) GO INSERT INTO Categories V ALUES(LA01, 语言 ) GO -向 Books 表导入数据USE BlueSkyDB GO INSERT INTO Books VALUES(SQL Server 2005 实现与维护 ,9787302163305,Solid Quality Learning,79.00,CO01) GO INSERT INTO Books VALUES(ASP.NET 2.0入门经典 ,9787115158284,Scott Mitchell,49.00,CO01) GO INSERT
15、INTO Books VALUES(英语阅读词汇双突破,7560922171,杨建荣 ,15.50,LA01) GO INSERT INTO Books VALUES(杜拉拉升职记 ,9787561339121,NULL,26.00,FI01) GO INSERT INTO Books VALUES(夏洛的网 ,7532733416,NULL,17.00,FI01) GO INSERT INTO Books VALUES(新编日语 ,9787810097987,周平 ,11.80,LA01) GO INSERT INTO Books VALUES(管理信息系统 ,7111156242,祝士明
16、,21.00,NULL) GO INSERT INTO Books VALUES(系统防真导论 ,730203821x,肖田元 ,23.50,NULL) GO INSERT INTO Books VALUES(Java编程思想 ,711116220 x,Bruce Eckel,95.00,CO01) GO INSERT INTO Books VALUES(C#与 ASP.NET 程序设计 ,7560519636,曹锰 ,29.00,CO01) GO -向 Customers 表导入数据USE BlueSkyDB GO INSERT INTO Customers V ALUES( 张志远 ,12
17、345678) GO INSERT INTO Customers V ALUES( 李涛 ,12345678) GO INSERT INTO Customers V ALUES(Scottfield,S,12345678) GO -向 Orders 表导入数据USE BlueSkyDB GO 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 15 页 - - - - - - - - - INSERT INTO Orders V ALUES(2008-12-14,2008-1
18、2-17,3) GO INSERT INTO Orders V ALUES(2008-12-15,2008-12-18,1) GO INSERT INTO Orders V ALUES(2009-2-12,2009-2-15,1) GO INSERT INTO Orders V ALUES(2009-3-1,2009-3-4,2) GO INSERT INTO Orders V ALUES(2009-3-15,NULL,3) GO INSERT INTO Orders V ALUES(2009-3-16,NULL,1) GO -向 OrderItems 表导入数据USE BlueSkyDB G
19、O INSERT INTO OrderItems VALUES(1,1,1,71.10) GO INSERT INTO OrderItems VALUES(1,2,1,36.90) GO INSERT INTO OrderItems VALUES(2,6,10,10.03) GO INSERT INTO OrderItems VALUES(3,9,1,85.50) GO INSERT INTO OrderItems VALUES(3,10,1,26.10) GO INSERT INTO OrderItems V ALUES(4,1,2,71.10) GO INSERT INTO OrderIt
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年图书管理系统 2022 图书 管理 系统
限制150内