--創建數據庫use master --切換到master數據庫
go-- 終止所有與SaleManagerDB數據庫的連接alterdatabase SaleManagerDB set single_user withrollback immediate
goifexists(select*from sysdatabases where name='SaleManagerDB')dropdatabase SaleManagerDB
gocreatedatabase SaleManagerDB
onprimary(name='SaleManagerDB_data',filename='D:\DB\SaleManagerDB_data.mdf',size=10MB,filegrowth=1MB
)
log on(name='SaleManagerDB_log',filename='D:\DB\SaleManagerDB_log.ldf',size=2MB,filegrowth=1MB
)
go
2.在數據庫中創建表
use SaleManagerDB
go
--商品分類表ifexists(select*from sysobjects where name='ProductCategory')droptable ProductCategory
go
createtable ProductCategory
(CategoryId intidentity(1,1)primarykey,--商品分類編號CategoryName varchar(20)notnull--商品分類名稱)
go
--商品計量單位表ifexists(select*from sysobjects where name='ProductUnit')droptable ProductUnit
go
createtable ProductUnit
(Id intidentity(1,1)primarykey,Unit varchar(20)notnull--商品計量單位)
go
--商品信息表ifexists(select*from sysobjects where name='Products')droptable Products
go
createtable Products
(ProductId varchar(50)primarykey,--商品編號(商品條碼)ProductName varchar(50)notnull, UnitPrice numeric(5,2)notnull,Unit varchar(50)notnull,--計量單位(為了提高效率,該字段并沒有使用外鍵)Discount int,--折扣CategoryId intreferences ProductCategory (CategoryId)notnull--(商品分類)外鍵)
go
--商品庫存狀態ifexists(select*from sysobjects where name='InventoryStatus')droptable InventoryStatus
go
createtable InventoryStatus
( StatusId intprimarykey,--庫存狀態StatusDesc varchar(50)notnull--(1:正常,-1:低于庫存,2:高于庫存;-2:已清倉))
go
--商品庫存信息ifexists(select*from sysobjects where name='ProductInventory')droptable ProductInventory
go
createtable ProductInventory
(ProductId varchar(50)primarykey,--商品編號TotalCount intnotnull,--總數量MinCount intnotnull,--最小庫存MaxCount intnotnull,--最大庫存StatusId intreferences InventoryStatus (StatusId)--庫存狀態(1:正常,-1:低于庫存,2:高于庫存;-2:已清倉))
go
--銷售員表ifexists(select*from sysobjects where name='SalesPerson')droptable SalesPerson
go
createtable SalesPerson
(SalesPersonId intidentity(10000,1)primarykey,-- 自動標識SPName varchar(50)notnull,LoginPwd varchar(50)notnull--最少6位 )
go
--銷售流水賬ifexists(select*from sysobjects where name='SalesList')droptable SalesList
go
createtable SalesList
( SerialNum varchar(50)primarykeynotnull,--流水號(系統自動生成)TotalMoney numeric(10,2)notnull,--購物總價錢RealReceive numeric(10,2)notnull,--實際收款ReturnMoney numeric(10,2)notnull,--找零SalesPersonId intreferences SalesPerson (SalesPersonId),--銷售員(外鍵)SaleDate smalldatetime default(getdate())notnull--默認數據庫服務器時間)
go
--銷售流水賬明細ifexists(select*from sysobjects where name='SalesListDetail')droptable SalesListDetail
go
createtable SalesListDetail
(Id intidentity(1000000,1)primarykeynotnull,--自動標識列SerialNum varchar(50)references SalesList (SerialNum),--流水號(外鍵)ProductId varchar(50)notnull,--商品編號(不需要外鍵)ProductName varchar(50)notnull,UnitPrice numeric(10,2)notnull,Discount int,--折扣Quantity intnotnull,--銷售數量 SubTotalMoney numeric(10,2)--小計金額)
go
--商品入庫表ifexists(select*from sysobjects where name='ProductStorage')droptable ProductStorage
go
createtable ProductStorage
(StorageId intidentity(100000,1)primarykey,--標識列ProductId varchar(50)references Products (ProductId),--外鍵AddedCount intnotnull,--入庫數量CurrentTime smalldatetime default(getdate())notnull--默認數據庫服務器時間)
go
--登錄日志ifexists(select*from sysobjects where name='LoginLogs')droptable LoginLogs
go
createtable LoginLogs
(LogId intidentity(1,1)primarykey,LoginId intnotnull,SPName varchar(50),--登錄人員姓名ServerName varchar(100),--登錄的服務器名稱LoginTime datetimedefault(getdate())notnull,--默認數據庫服務器時間ExitTime datetime--退出時間)
go
--超市會員表ifexists(select*from sysobjects where name='SMMembers')droptable SMMembers
go
createtable SMMembers
(MemberId intidentity(100200300,1)primarykey,--會員卡號MemberName varchar(50)notnull,--會員姓名 Points intdefault(0)notnull,--會員積分(消費10元,獲得1個積分)PhoneNumber varchar(200)notnull,--聯系電話MemberAddress textnotnull,--聯系地址OpenTime datetimedefault(getdate()),--開戶時間MemberStatus intdefault(1)notnull--會員卡狀態(1:正常使用;0:凍結;-1:注銷))
go
--管理員表ifexists(select*from sysobjects where name='SysAdmins')droptable SysAdmins
go
createtable SysAdmins
(LoginId intidentity(2000,1)primarykey,--登錄賬號LoginPwd varchar(20),--登錄密碼AdminName varchar(20),--管理員姓名AdminStatus bit,--當前狀態(1:啟用;0:禁用)RoleId int--角色編號(1:超級管理員;2:一般管理員))
go
HTML 等價字符引用:系統化記憶指南
在 HTML 中,字符引用(Character Entity References)用于表示保留字符或特殊符號。我將提供一個系統化的方法來記憶這些重要實體,并解釋它們的實際應用。
什么是等價字符引用?
HTML 字符引用有兩種形式: 命名實體:&entity_name…
2021年由Hashim等人提出(論文:Honey Badger Algorithm: A New Metaheuristic Algorithm for Solving Optimization Problems)。模擬蜜獾在自然界中的智能捕食行為,屬于群體智能優化算法(與粒子群PSO、遺傳算法GA同屬一…