一、设计出实体E-R图

二、根据E-R图设计出数据表
客户基本信息表:Customer
|
字段名称 |
字段类型 |
是否为空 |
含义 |
|
CustomerID |
Int |
Not null |
主键,自增 |
|
CustomerNumber |
nVarchar(50) |
Not null |
客户编号 |
|
CustomerName |
nVarchar(50) |
Not null |
客户名称 |
|
CustomerPhone |
Varchar(20) |
null |
客户电话 |
|
CustomerFax |
Varchar(20) |
null |
客户传真 |
|
LinkmanID |
int |
null |
外键,主联系人 |
|
CustomerAddress |
nVarchar(255) |
null |
客户地址 |
|
CustomerEmail |
Varchar(20) |
null |
客户电邮 |
|
SalesmanID |
int |
Not null |
外键,业务员 |
|
CustomerTypeID |
int |
Not null |
外键,客户类型 |
|
CustomerStageID |
int |
Not null |
外键,客户阶段 |
|
CustomerStateID |
int |
Not null |
外键,客户状态 |
|
CustomerLevelID |
int |
Not null |
外键,客户级别 |
|
CustomerRemark |
text |
null |
备注信息 |
|
CustomerSourceID |
int |
Not null |
外键,客户来源 |
|
IndustryTypeID |
int |
Not null |
外键,行业类别 |
|
AreaID |
int |
null |
外键,地区 |
|
Website |
Varchar(20) |
null |
网址 |
|
AddDate |
datetime |
Not null |
添加日期 |
|
Consumption |
money |
Not null |
消费总额,默认为0 |
|
Debt |
money |
Not null |
欠款总额,默认为0 |
|
Maintenance |
money |
Not null |
维护费用,默认为0 |
|
Integral |
bigint |
Not null |
客户积分,默认为0 |
|
OtherInfo |
text |
null |
客户其它信息 |
|
CompetitorInfo |
text |
null |
竞争对手信息 |
基础表:Base_Name
|
字段名称 |
字段类型 |
是否为空 |
含义 |
|
BaseNameID |
Int |
Not NULL |
主键,自增 |
|
BaseName |
Nvarchar(10) |
Not Null |
类别名称 |
基础表内容:Base_Details
|
字段名称 |
字段类型 |
是否为空 |
含义 |
|
BaseDetailsID |
Int |
Not NULL |
主键,自增 |
|
BaseNameID |
Int |
Not NULL |
外键,类别名称 |
|
BaseDetails |
Text |
NULL |
基础内容 |
|
IsDefault |
Bit |
NULL |
是否默认 |
地区表:Area_Rec
|
字段名称 |
字段类型 |
是否为空 |
含义 |
|
AreaID |
int |
Not null |
主键,自增 |
|
AreaName |
Nvarchar(15) |
Not null |
地名 |
|
FatherID |
Int |
Not null |
父级ID,无则为0 |
|
AreaLevel |
Int |
Not null |
层级 |
|
ZIP |
Varchar(10) |
null |
邮编 |
员工表:Employee
|
字段名称 |
字段类型 |
是否为空 |
含义 |
|
EmployeeID |
int |
Not null |
主键,自增 |
|
EmployeeNumber |
Varchar(20) |
Not null |
用户编号 |
|
EmployeeName |
Nvarchar(15) |
Not NUll |
员工姓名 |
|
PWD |
Varchar(30) |
Not NULL |
员工密码 |
|
SexID |
Int |
Not NULL |
外键,性别 |
|
BirthDay |
Datetime |
Not Null |
出生日期 |
|
IDCard |
Varchar(30) |
Not Null |
身份证号 |
|
EducationID |
Int |
Not Null |
外键,学历 |
|
DepartmentID |
Int |
NOT NULL |
外键,部门 |
|
DutiesID |
Int |
Not Null |
外键,职务 |
|
Telphone |
Varchar(20) |
Null |
手机 |
|
Phone |
Varchar(15) |
NULL |
电话 |
|
PowerID |
Int |
Not Null |
外键,所属权限组 |
|
State |
Int |
Not nuLL |
外键,用户状态 |
|
Address |
Text |
Null |
家庭住址 |
|
Remark |
Text |
Null |
备注 |
公司信息表:Company
|
字段名称 |
字段类型 |
是否为空 |
含义 |
|
CompanyID |
Int |
Not Null |
主键,自增 |
|
CompanyName |
Nvarchar(20) |
NOT NULL |
公司名称 |
|
Phone |
Varchar(20) |
Null |
公司电话 |
|
Address |
Nvarchar(30) |
Null |
公司地址 |
商品信息表:Goods
|
字段名称 |
字段类型 |
是否为空 |
含义 |
|
GoodsID |
Int |
NOT NULL |
主键,自增 |
|
GoodsNumber |
Varchar(20) |
Not null |
商品编号 |
|
GoodsName |
nVarchar(20) |
NOT NULL |
商品名称 |
|
GoodsTypeID |
Int |
NOT NULL |
外键,商品类型 |
|
GoodsModel |
Int |
NOT NULL |
外键,规格型号 |
|
UnitID |
Int |
Not NULL |
外键,单位 |
|
Cost |
Money |
NOt nULL |
成本价格,默认为0 |
|
Sale |
Money |
Not null |
销售单价,默认为0 |
|
GoodsCount |
Bigint |
Not null |
商品数量,默认为0 |
|
IsCount |
Bit |
Not Null |
是否使用数量 |
|
Remark |
Text |
Null |
备注 |
客户与员工关系表:Customer_Rel_Employee
|
字段名称 |
字段类型 |
是否为空 |
含义 |
|
Id |
Int |
Not null |
主键,自增 |
|
CustomerID |
Int |
Not null |
外键,客户ID |
|
EmployeeID |
Int |
Not Null |
外键,员工ID |
命名规范:
1、表命名规范
1) 对象_内容 :Customer_BankAccount
2) 对象_内容_特殊类型:Customer_Detail_Rec 表示它里面用了递归属性
3) 对象_内容1_Rel_内容2:Customer_Detail_Rel_Type 表示内容1与内容2 N:N的关系。
2、字段名命名规范
1) 骆驼命名法:PropertyDetailItemID
3、存储过程命名
1) 层名_对象名__窗体名UIL_Customer__frm_Customer
三、在MS创建相应的表
四、建立查增删改的存储过程