首页 > 代码库 > DBS:同学录

DBS:同学录

ylbtech-DatabaseDesgin:ylbtech-cnblogs(博客园)-数据库设计-2,Admin(用户后台)

DatabaseName:同学录

Model:

Type:

Url:

1.A,数据库关系图(Database Diagram) 返回顶部

 

1.B,数据库设计脚本(Database Design Script)返回顶部
-- =============================================-- Create database template-- =============================================USE masterGO-- Drop the database if it already existsIF  EXISTS (    SELECT name         FROM sys.databases         WHERE name = Nclassbook)DROP DATABASE classbookGOCREATE DATABASE classbookGOuse classbookgo-- =============================================-- Create Table 班级表-- =============================================create table class(classid int identity primary key,    --编号name varchar(100) not null            --名称)-- =============================================-- Create Table 留言表-- =============================================create table newsboard(newsboardid int identity primary key,    --编号title varchar(2000) not null,            --名称username varchar(20),                    --留言人headimage varchar(100),                    --头像pubdate datetime default(getdate())        --留言时间)-- =============================================-- Create Table 用户表-- =============================================create table users(usersid int identity(720001,1) primary key,        --编号pwd varchar(20) not null,                --密码[power] varchar(20) check([power]=admin or [power]=guest) default(guest),    --级别pubdate datetime default(getdate())        --申请日期)-- =============================================-- Create Table 学生表-- =============================================create table student(studentid int identity primary key,        --编号name varchar(20),                --姓名sex varchar(2) check(sex=or sex=) default(),    --性别age int,                                --年龄qq varchar(100),                        --QQ号[e-mail] varchar(100),                    --邮箱tel varchar(100),                        --固话address varchar(1000),                    --所在地phone varchar(100),                        --电话headimage varchar(1000),                --头像图片classid int  foreign key references class(classid) not null, --班级编号usersid int foreign key references users(usersid) not null     --用户编号    )-- =============================================-- Create Table 短信表-- =============================================create table messages(messageid int identity(720001,1) primary key,--编号title varchar(1000),                         --标题    body varchar(2000),                            --内容pubdate datetime default(getdate()),        --发布日期inboxid int,                                --发信人的编号outboxid int,                                --收信人的编号inboxname varchar(20),                        --发信人姓名    outboxname varchar(20),                        --收信人姓名dal int default(0)                            --是否已读,0:没读,1:已读)--插入一些测试信息insert users(pwd,[power]) values(888888,admin)insert class(name) values(T03)select @@identityselect * from classselect * from usersselect * from newsboardselect * from studentselect * from messagesinsert student(name,sex,age,qq,[e-mail],tel,address,phone,classid,usersid)values(‘‘,,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘,1,720001)insert student(name,sex,age,qq,e-mail,tel,address,phone,classid,usesrid)values()select studentid,name,sex,age,qq,[e-mail],tel,address,phone,headimage,classid,usersid from studentselect studentid from student where usersid=720002
View Code
1.C,功能实现代码(Function Implementation Code)返回顶部

 

warn作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。