use master
go
if exists(select * from sysdatabases where name='learning')
drop database learning
go
CREATE DATABASE learning
ON
( NAME='learning_data', --主数据文件的逻辑名称
FILENAME='E:\SQLlearning\learning.mdf', -- 主数据文件的物理名称
SIZE=10MB, --主数据文件的初始大小
MAXSIZE=50MB, -- 主数据文件增长的最大值
FILEGROWTH=% --主数据文件的增长率
)
--/*--日志文件的具体描述,各参数含义同上--*/
LOG ON(
NAME='learning_log',
FILENAME='E:\SQLlearning\learning.ldf',
SIZE=5MB,
MAXSIZE=25MB,
FILEGROWTH=5MB)
GO USE learning
GO
--在视图sysobjects中查找是否存在userInfo表格
if exists(select * from dbo.sysobjects where name='userInfo')
drop table userInfo
GO
--用户信息表格
create table userInfo
(
userId int not null, --自增长ID
userName varchar() not null, --用户姓名
password varchar() not null, --用户密码
email varchar() not null, --用户邮箱
userRole int, --用户角色(:普通会员,1管理员)
registerDate varchar() --注册时间(默认当前时间)
)
--员工信息表格
if exists(select * from sysobjects where name='employInfo')
drop table employInfo
GO
create table employInfo
(
employId int not null, --自增长ID
employNumber varchar() not null, --员工编号
employPassword varchar() not null, --员工密码(默认6个8)
employRealName varchar() not null, --员工真实姓名
employPhoneNum varchar() not null --员工联系电话 ) --员工业绩表格
if exists(select * from dbo.sysobjects where name='employResult')
drop table employResult
GO
create table employResult
(
employResultId int not null, --自增长ID
employResultNum varchar() not null, --业绩编号
employNumber varchar() not null, --员工编号
houseNumber varchar() not null, --房屋编号
houseAmount float, --房屋售价/出租价
percentPaid float, --提成比例(%提成)
salesCompleted varchar(), --销售完成时间
) --房屋信息表格
if exists(select * from dbo.sysobjects where name='houseInfo')
drop table houseInfo
GO
create table houseInfo(
houseId int not null, --自增长ID
houseNumber varchar() not null, --房屋编号
userName varchar() not null, --房屋发布会员
employNumber varchar() not null, --房屋对应负责销售员工编号(唯一主键)
informationType int not null, --判断是发布出租/出售房屋类型(0代表发布出租信息,1代表发布出售信息)
houseOwnerName varchar() not null, --业主姓名
houseOwnerSex int not null, --业主性别(:代表男,:代表女)
houseOwnerPhoneNumber varchar(), --联系电话
houseArea varchar() not null, --房屋所在区域
houseSize int not null, --房屋面积
houseFloor int, --房屋出租/出售 楼层
houseTotalFloor int, --房屋总楼层数
HouseUnit varchar(), --房屋户型(一室一厅,二室一厅,)[数据存储值为:一室二厅]
BudgetPrice float, --预算价格
SpecificAddress varchar() not null, --房屋具体地址
houseFloorType int not null, --楼型,,[:代表高层,:代表多层,:平房,:其他]
otherRequirements varchar() --其他信息
) --房产资讯表格 if exists(select * from dbo.sysobjects where name='houseNews')
drop table houseNews
GO
create table houseNews(
houseNewId int not null, --自增长ID
houseNewTheme varchar() not null, --咨询主题
houseNewContent text, --咨询内容
houseNewDate varchar() --发布日期
) --留言评论表
if exists(select * from dbo.sysobjects where name='Message')
drop table Message
GO
create table Message(
messageId int not null, --自增长ID
houseNumber varchar() not null, --房屋出租/出售编号(针对房屋编号留言)
messageContent varchar() not null, --留言内容
contact varchar(), --联系方式
messageDate varchar() not null --留言时间
) --添加约束
alter table userInfo add constraint pk_userId primary key(userId);
alter table userInfo add constraint DF_userRole default()for userRole;
alter table userInfo add constraint DF_registerDate default(CONVERT(varchar(),GETDATE(),)) for registerDate; alter table houseInfo add constraint pk_houseId primary key(houseId); alter table employInfo add constraint pk_employInfo primary key(employId);
alter table employInfo add constraint DF_employPassword default('')for employPassword; alter table employResult add constraint pk_employResult primary key(employResultId); alter table houseNews add constraint pk_houseNewId primary key(houseNewId);
alter table houseNews add constraint DF_houseNewDate default(CONVERT(varchar(),GETDATE(),)) for houseNewDate; alter table T_Message add constraint pk_messageId primary key(messageId);
alter table T_Message add constraint DF_messageDate default(CONVERT(varchar(),GETDATE(),))for messageDate; GO

最新文章

  1. 人工智能之一《tensorflow》
  2. Shell文件权限和脚本执行
  3. 深入理解Android之Gradle
  4. hadoop单节点windows 7 环境搭建
  5. memcached +mysql+php 测试例子
  6. 【CentOS】搭建Web服务器
  7. c#与vb.net在App_Code里面编译要通过,需要以下web.config的配置
  8. SyntaxHighlighter -- 代码高亮插件
  9. redis info命令结果释疑
  10. 《Nagios系统监控实践》一书出版
  11. struct和typedef struct的用法
  12. 杂谈之不同行业的Solr
  13. 简单的划分数问题<划分问题>
  14. struts2 之 Action的优化配置
  15. DOM中元素对象的属性方法
  16. openshift上使用devicemapper
  17. html+ashx制作网页发布之后遇到的问题
  18. C/C++中const关键字
  19. Java 接口和多态
  20. python开发_tkinter_单选菜单_不可用菜单操作

热门文章

  1. Python中绘制场景热力图
  2. [The Preliminary Contest for ICPC Asia Nanjing 2019] A-The beautiful values of the palace(二维偏序+思维)
  3. Dictionary的用法及用途
  4. java设计模式5.组合模式、门面模式、享元模式、桥接模式
  5. C# 生产者与消费者模式
  6. CodeForces 1107 F Vasya and Endless Credits
  7. poj 3026 Borg Maze(最小生成树+bfs)
  8. DevExpress的GridView,为每行的动态绑定不同的RepositoryItemLookUpEdit
  9. Springboot基于enable模块驱动
  10. linux下创建git代码