百度首页 | 百度空间
 
查看文章
 
asp.net SQL2005 学习笔记
2007年07月09日 星期一 上午 09:00
asp.net 日记 2007/7/9
vs.net 2005 +SQLserver2005
WEB用户控件
--foreign key 的使用
id int foreign key references voteMaster(id),
--inserted
零时表


-- 创建管理员信息表

create database vote '创建数据库
use vote '
使用数据库
create table admin
(
   id
int identity (1,2)  primary key, --主键
  
username varchar(20) not null, --管理员登录密码
  
password varchar(20) not null-- 登录密码
)
insert into admin (username,password) values('benben','benben')
select * from admin

--投票主表
create table votemaster
(
    id
int identity (1,1) primary key,
    voteTitle
varchar(30) not null , --投票标题
   
voteSum int default(0) --对应投票的票数
)

insert into votemaster (voteTitle) values('哈哈,打字真爽')
select * from voteMaster
--创建投票详表
create table voteDetails
(
    voteDetails
int identity (1,1) primary key,
    voteItem
varchar(20) not null,
    voteNum
int default (0)
    id
int foreign key references voteMaster(id),
   
--映射voteDetails id到voteMaster的id.(外键的作用)
)
drop table voteDetails --删除表

--存储过程
--触发器
create trigger UpdateVoteSum
on voteDetails
for upDate
as
begin
    update
voteMaster set votesum=voteSum+1 where id=(select top 1 id from inserted)
end

--创建系统配置信息表
create table voteConfig
(
     id
int foreign key references voteMaster(id),--设置系统前台投票选项
    
checkIP int default(0),--系统是否需要限制IP
    
checkTime int default(0),--限制系统时间
)

--限制时间IP表
create table ip
(
    id
int foreign key references VoteMaseter(id),
    ip
varchar(30) not null ,
    votetime datetime
default(getdate())
    voteNum
int default(1),--该
)

类别:学习笔记 | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码:
 

     

©2008 Baidu