数据库脚本

drop table crm_user_info;
drop table crm_work_customer_relation;
drop table crm_business;
drop table crm_travel;
drop table crm_contact_log;
drop table crm_order;
drop table crm_order_detail;
drop table crm_gods;
drop table crm_judge;
drop table crm_advice;
drop table crm_message; --用户基本信息表(包括超级管理员。企业人员,客户)
create table crm_user_info(
crm_id integer primary key, /*ID主键*/
email varchar2(50) not null, /*email作为登录账号*/
passwords varchar2(50) not null, /*密码使用加密*/
cname varchar2(50), /*用户真实名*/
phone varchar2(25), /*电话*/
sex integer, /*性别*/
age integer, /*年龄*/
address varchar2(200), /*地址*/
userlevel integer not null, /*用户级别0:A 1:B 2:C 3:D */
pl integer not null, /*系统权限等级 3 2 1 0*/
bussiness_id integer not null, /*企业ID*/
createdate date ); /*上次登录时间*/ create sequence seq_crm_user_info_seq INCREMENT BY 1 START WITH 1001; --员工-客户关系表
create table crm_work_customer_relation(
crm_cid integer not null,
crm_eid integer not null
); --企业表
create table crm_business(
business_id integer primary key, /*企业ID*/
business_name varchar2(50) not null, /*企业名称*/
business_type varchar2(200) not null ); /*企业经营范围*/ create sequence seq_crm_business_seq INCREMENT BY 1 START WITH 101; --行程表
create table crm_travel(
t_id integer primary key, /*行程序列化自增ID*/
c_id integer not null, /*客户ID*/
e_id integer not null, /*员工ID*/
state integer not null, /*状态 finish:0 ready:1 */
t_time date not null, /*安排时间*/
mission varchar2(1000) not null, /*任务具体*/
t_type integer not null, /*类型(电话或者上訪) call:0 go:1*/
address varchar2(200), /*上訪地址*/
c_remark varchar2(1000) ); /*备注*/ create sequence seq_crm_travel_seq INCREMENT BY 1 START WITH 1001; --联系记录表
create table crm_contact_log(
cl_id integer primary key, /*记录编号自增1*/
t_type integer not null, /*记录类型(电话0或者上訪1)*/
c_id integer not null, /*客户ID*/
e_id integer not null, /*员工ID*/
c_record varchar2(2000), /*记录内容*/
c_result varchar2(200) not null, /*结果*/
c_time date not null ); /*时间*/ create sequence seq_crm_contact_log_seq INCREMENT BY 1 START WITH 1001; --订单表
create table crm_order(
o_id integer primary key, /*订单表ID自增一*/
c_id integer not null, /*客户ID*/
e_id integer not null, /*员工ID*/
address varchar2(200) not null ); /*收货地址*/ create sequence seq_crm_order_seq INCREMENT BY 1 START WITH 1001; --订单具体表
create table crm_order_detail(
od_id integer primary key, /*订单具体表ID自增一*/
o_id integer not null, /*订单表ID*/
g_id integer not null, /*商品编号*/
od_num integer not null, /*订货数量*/
od_remark varchar2(200) not null, /*交易备注*/
state integer not null, /*状态 ok:0 ready:1 cancel:2 undefine:3*/
odate date not null, /*下单时间*/
udate date not null ); /*订单更新时间*/ create sequence seq_crm_order_detail_seq INCREMENT BY 1 START WITH 10001; --商品表
create table crm_gods(
g_id integer primary key, /*商品编号*/
g_name varchar2(45) not null, /*名称*/
g_color varchar2(45) not null, /*颜色*/
g_size varchar(10) not null, /*规格*/
g_price number not null, /*原价*/
g_rprice number not null ); /*出售价*/ create sequence seq_crm_gods_seq INCREMENT BY 1 START WITH 1001; --对客户的评定表
create table crm_judge(
j_id integer primary key,
c_id integer not null, /*客户ID*/
e_id integer not null, /*员工ID*/
j_comment varchar2(2000) not null ); /*评价内容*/ create sequence seq_crm_judge_seq INCREMENT BY 1 START WITH 1001; --建议表
create table crm_advice(
a_id integer primary key, /*建议表主键ID,自增一*/
a_time date not null, /*建议时间*/
e_id integer not null, /*客户ID*/
a_advice varchar2(2000) not null, /*建议内容*/
business_id integer not null ); /*公司ID*/ create sequence seq_crm_advice_seq INCREMENT BY 1 START WITH 1001; --留言表
create table crm_message(
m_id integer primary key,
c_id integer not null, /*客户ID*/
business_id integer not null, /*企业ID*/
m_message varchar2(2000), /*内容*/
m_feedback varchar2(2000), /*反馈*/
m_isfeedback integer not null, /*是否已经反馈ok:0 ready:1*/
m_time date not null ); /*留言时间*/ create sequence seq_crm_message_seq INCREMENT BY 1 START WITH 10001;
commit;

由于是单纯的小项目。只用于练习使用框架而练手的。表设计的不合理之处非常多。也没有想那么多。

我是菜鸟。我在路上。

三期_day02_数据库表设计和开发准备工作的更多相关文章

  1. Oracle数据库表设计时的注意事项

    表是Oracle数据库中最基本的对象之一.万丈高楼从平地起,这个基础对象对于数据库来说,非常重要.因为其设计是否合理,直接跟数据库的性能相关.从Oracle数据库菜鸟到数据库专家这个过程中,在表设计与 ...

  2. 数据库表设计时一对一关系存在的必要性 数据库一对一、一对多、多对多设计 面试逻辑题3.31 sql server 查询某个表被哪些存储过程调用 DataTable根据字段去重 .Net Core Cors中间件解析 分析MySQL中哪些情况下数据库索引会失效

    数据库表设计时一对一关系存在的必要性 2017年07月24日 10:01:07 阅读数:694 在表设计过程中,我无意中觉得一对一关系觉得好没道理,直接放到一张表中不就可以了吗?真是说,网上信息什么都 ...

  3. Innodb IO优化 — 数据库表设计 转

    数据库表设计这块学问比较多,我这里单从互联网角度出发同时结合Innodb的特性给出一些设计方法供大家参考.本文构建大概分两分部分:Innodb的特性及设计中如何利用这种特性. Innodb特性: In ...

  4. springmvc 项目完整示例01 需求与数据库表设计 简单的springmvc应用实例 web项目

    一个简单的用户登录系统 用户有账号密码,登录ip,登录时间 打开登录页面,输入用户名密码 登录日志,可以记录登陆的时间,登陆的ip 成功登陆了的话,就更新用户的最后登入时间和ip,同时记录一条登录记录 ...

  5. mysql设计与优化以及数据库表设计与表开发规范

    一.设计问题? 1.主键是用自增还是UUID ? Innodb 中的主键是聚簇索引. 如果主键是自增的,那么每次插入新的记录,记录就会顺序添加到当前索引节点的后续位置,当一页写满,就会自动开辟一个新的 ...

  6. ERP开发分享 1 数据库表设计

    这是我的ERP设计经验分享系列,今天讲的是数据库的表设计(1),主要阐述: 1.单字段的主键:2.使用int32作为主键类型:3.使用版本字段处理乐观锁定:4.生效字段标明是否允许“被使用”:5.锁定 ...

  7. 海量数据GPS定位数据库表设计

    在开发工业系统的数据采集功能相关的系统时,由于数据都是定时上传的,如每20秒上传一次的时间序列数据,这些数据在经过处理和计算后,变成了与时间轴有关的历史数据(与股票数据相似,如下图的车辆行驶过程中的油 ...

  8. 转一篇MYSQL文章《数据库表设计,没有最好只有最适合》

    http://mp.weixin.qq.com/s/a8klpzM5iam0_JYSw7-U4g 我们在设计数据库的时候,是否会突破常规,找到最适合自己需求的设计方案,下面来举个例子: 常用的邻接表设 ...

  9. Acitiviti数据库表设计(学习笔记)

    ACT_ID_*:与权限,用户与用户组,以及用户与用户组关系相关的表 ACT_RU_*:代表了流程引擎运行时的库表,RU表示Runtime ACT_HI_*:HI表示History当流程完成了节点以后 ...

随机推荐

  1. POJ2142 The Balance (扩展欧几里德)

    本文为博主原创文章,欢迎转载,请注明出处 www.cnblogs.com/yangyaojia The Balance 题目大意  你有一个天平(天平左右两边都可以放砝码)与重量为a,b(1<= ...

  2. Ubuntu PostgreSql主从切换

    主机:192.168.100.70 从机:192.168.100.71 通用配置(即主从都要配置) 修改/etc/postgresql/10/main/pg_hba.conf host all all ...

  3. HDU 4313 Contest 2

    很明显的树形DP了.但网上有的说可以用并查集.... 考虑一棵子树,当根结点有机器人时,则必定所有子树都要和根结点断开,而根结点向上返回的路径值则为其父结点与根结点连边的权值. 当根结点安全时,假设其 ...

  4. node.js mongodb ReplSet

    随着web2.0兴起,高并发大数据量的应用对数据库高速响应的性能要求日趋明显,传统的关系型数据库在这方面显得有些乏力.有矛自有盾,内存DB的出现弥补了传统关系型db的不足.眼下市面流行的内存db主要有 ...

  5. Cocos2d-x-lua学习点滴

    Lua下的方法.自己项目经验,个人见解,不能确保正确. Sprite: local Light = CCSprite:create("light.png")             ...

  6. hdoj 4548 美素数 【打表】

    另类打表:将从1到n的满足美素数条件的数目赋值给prime[n],这样最后仅仅须要用prime[L]减去prime[R-1]就可以: 美素数 Time Limit: 3000/1000 MS (Jav ...

  7. MySQL超级简明基本操作攻略,给自己看(一)

    系统:Ubuntu 14.04 LTS 安装: apt-get install mysql //安装数据库 apt-get install mysql-workbench //安装图形界面 使用: 启 ...

  8. iOS开发- 生成/解析.vcf文件

    vcf, 通讯录导出的一种格式. 一.生成vcf文件 假设要把我们iPhone通讯录里的数据, 生成vcf格式文件. 我们能够借助iCloud. 小技巧:通过iCloud导出iPhone通讯录的方法 ...

  9. 4.git "Could not read from remote repository.Please make sure you have the correct access rights."解决方案

    转自:https://zhiku8.com/git-could-not-read-from-remote-repository.html 我们在使用git clone 或其他命令的时候,有时候会遇到这 ...

  10. Go语言结构体转json的坑

    Go语言结构体转json的坑 标签(空格分隔): go json.Marshal() JSON输出的时候必须注意,只有导出的字段(首字母是大写)才会被输出,如果修改字段名,那么就会发现什么都不会输出, ...