一、智能商超管理E-R图
在智慧社区商超管理系统中,通常有多种不同角色的人员使用该系统,超市里有各类不同的商品,商品都有不同的供应商。常将此关系转换为E-R图,智能商超的E-R如下:
二、E-R图转换成表格如下:
1、收银员
2、销售
3、商品
4、录入
5、供应商
6、库管员
三、SQL Server 中的信息导入到C#中需要添加以下代码:
using System.Data.SqlClient;
四、附录
SQL中代码如下:
USE [z.2017270387]
GO
/****** Object: Table [dbo].[销售] Script Date: 11/02/2018 15:30:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[销售](
[time] [datetime] NULL,
[role] varchar NOT NULL,
[productinfo] varchar NULL,
CONSTRAINT [PK_销售] PRIMARY KEY CLUSTERED
(
[role] 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: 11/02/2018 15:30:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[收银员](
[id] [int] NOT NULL,
[name] nchar NULL,
[password] varchar NULL,
[tel] varchar NULL,
CONSTRAINT [PK_收银员] PRIMARY KEY CLUSTERED
(
[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
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[商品] Script Date: 11/02/2018 15:30:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[商品](
[id] [int] NOT NULL,
[name] varchar NOT NULL,
[price] [decimal](6, 2) NULL,
[address] varchar NULL,
CONSTRAINT [PK_商品] PRIMARY KEY CLUSTERED
(
[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
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[录入] Script Date: 11/02/2018 15:30:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[录入](
[time] [datetime] NULL,
[product info] varchar NULL,
[role] varchar NOT NULL,
[number] varchar NULL,
CONSTRAINT [PK_录入] PRIMARY KEY CLUSTERED
(
[role] 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: 11/02/2018 15:30:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[库管员](
[name] varchar NULL,
[number] varchar NOT NULL,
[password] varchar NULL,
[tel] varchar NULL,
CONSTRAINT [PK_库管员] PRIMARY KEY CLUSTERED
(
[number] 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: 11/02/2018 15:30:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[供应商](
[code] varchar NOT NULL,
[name1] varchar NULL,
[address] varchar NULL,
[contact] varchar NULL,
[tel] varchar NULL,
CONSTRAINT [PK_供应商] PRIMARY KEY CLUSTERED
(
[code] 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