1.建库
CREATE DATABASE CompanySales
ON
( NAME = 'Sales_data',
FILENAME = 'D:\db\Sales_data.mdf' ,
SIZE = 10240KB ,
MAXSIZE = UNLIMITED, FILEGROWTH = 15%)
LOG ON
( NAME = 'Sales_log',
FILENAME = 'D:\db\Sales_log.ldf' ,
SIZE = 3072KB , MAXSIZE = 30720KB ,
FILEGROWTH = 1024KB )
2.建客户表
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Customer](
[CustomerID] [int] NOT NULL,
[CompanyName] [varchar](50) NULL,
[ContactName] [char](8) NULL,
[Phone] [varchar](20) NULL,
[Address] [varchar](100) NULL,
[EmailAddress] [varchar](50) NULL,
)CONSTRAINT [PK_customer] PRIMARY KEY CLUSTERED
(
[CustomerID] 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
SET ANSI_PADDING OFF
GO
3.建部门表
CREATE TABLE [dbo].[Department](
[DepartmentID] [int] NOT NULL,
[DepartmentName] [varchar](30) NULL,
[Manager] [char](8) NULL,
[Depart_Description] [varchar](50) NULL,
CONSTRAINT [PK_Department] PRIMARY KEY CLUSTERED
(
[DepartmentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
4.建员工表
CREATE TABLE [dbo].[Employee](
[EmployeeID] [int] NOT NULL,
[EmployeeName] [varchar](50) NULL,
[Sex] [char](2) NULL,
[BirthDate] [smalldatetime] NULL,
[HireDate] [smalldatetime] NULL,
[Salary] [money] NULL,
[DepartmentID] [int] NULL,
CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED
(
[EmployeeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
5.建商品表
CREATE TABLE [dbo].[Product](
[ProductID] [int] NOT NULL,
[ProductName] [varchar](50) NOT NULL,
[Price] [decimal](18, 2) NULL,
[ProductStockNumber] [int] NULL,
[ProductSellNumber] [int] NULL,
CONSTRAINT [PK_product] PRIMARY KEY CLUSTERED
(
[ProductID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
6.建供应商表
CREATE TABLE [dbo].[Provider](
[ProviderID] [int] NOT NULL,
[ProviderName] [varchar](50) NULL,
[ContactName] [char](8) NULL,
[ProviderAddress] [varchar](100) NULL,
[ProviderPhone] [varchar](15) NULL,
[ProviderEmail] [varchar](20) NULL,
CONSTRAINT [PK_Provider] PRIMARY KEY CLUSTERED
(
[ProviderID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
7.建采购订单表
CREATE TABLE [dbo].[Purchase_order](
[PurchaseOrderID] [int] NOT NULL,
[ProductID] [int] NULL,
[PurchaseOrderNumber] [int] NULL,
[EmployeeID] [int] NULL,
[ProviderID] [int] NULL,
[PurchaseOrderDate] [smalldatetime] NULL,
CONSTRAINT [PK_Purchase_order] PRIMARY KEY CLUSTERED
(
[PurchaseOrderID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
8.建销售订单表
CREATE TABLE [dbo].[Sell_Order](
[SellOrderID] [int] NOT NULL,
[ProductID] [int] NULL,
[SellOrderNumber] [int] NULL,
[EmployeeID] [int] NULL,
[CustomerID] [int] NULL,
[SellOrderDate] [smalldatetime] NULL,
CONSTRAINT [PK_Sell_Order] PRIMARY KEY CLUSTERED
(
[SellOrderID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
数据请自行添加
如有需要
可与我联系QQ:1207787189
我可以直接给你完整的数据库文档
你可以直接
附加