2018-11-04

1、根据.上述语义画出ER图。

2018-11-04_第1张图片
image.png

.2、将ER模型转换成数据表,并指出每个数据表的主键。

列名 数据类型 允许为空 备注
收银员表
工号 Int 否 主键
姓名 Varchar(50) 是
密码 Varchar(50) 是
电话 Varchar(15) 是
库管员表
列名 数据类型 允许为空 备注
工号 Int 否 主键
姓名 Varchar(50) 是
密码 Varchar(50) 是
电话 Varchar(15) 是
商品表
列名 数据类型 允许为空 备注
商品号 Int 否 主键
价格 Varchar(50) 是
名称 Varchar(50) 是

供应商表
列名 数据类型 允许为空 备注
代码 Int 否 主键
名称 Varchar(50) 是
地点 Varchar(50) 是
联系人 Varchar(50) 是
电话 Varchar(15) 是

3、根据建立的数据表,在SQL Server 2008中建表

USE [zhihuishangchao201727083]
GO
/****** Object: Table [dbo].[收银员] Script Date: 10/30/2018 16:28:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[收银员](
[工号] [int] NOT NULL,
[姓名] varchar NULL,
[密码] varchar NULL,
[电话] varchar NULL,
CONSTRAINT [PK_收银员] PRIMARY KEY CLUSTERED
(
[工号] 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
/****** Object: Table [dbo].[商品] Script Date: 10/30/2018 16:28:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[商品](
[商品号] [int] NOT NULL,
[商品名称] varchar NULL,
[价格] varchar NULL,
CONSTRAINT [PK_商品] PRIMARY KEY CLUSTERED
(
[商品号] 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
/****** Object: Table [dbo].[库管员] Script Date: 10/30/2018 16:28:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[库管员](
[工号] [int] NOT NULL,
[姓名] varbinary NULL,
[密码] varchar NULL,
[电话] varchar NULL,
CONSTRAINT [PK_库管员] PRIMARY KEY CLUSTERED
(
[工号] 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
/****** Object: Table [dbo].[供应商] Script Date: 10/30/2018 16:28:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[供应商](
[代码] [int] NOT NULL,
[名称] varchar NULL,
[地点] varchar NULL,
[联系人] varchar NULL,
[电话] varchar NULL,
CONSTRAINT [PK_供应商] PRIMARY KEY CLUSTERED
(
[代码] 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

你可能感兴趣的:(2018-11-04)