火车票售票系统

数据库售票系统@TOC
一、E-R图

火车票售票系统
二、创建表结构
1、创建“售票点”表,表名为sale
火车票售票系统

表结构为
火车票售票系统
2、创建“车票表”,表名为ticket
火车票售票系统
表结构为
火车票售票系统
3、创建“车次”表,表名为train
火车票售票系统
表结构为
火车票售票系统
4、创建“出售表”,表名为st
火车票售票系统
表结构为
火车票售票系统
三、事务控制
1、查询系统:
查询车次为T3025的列车的详细信息
Select*
from Train
Where Tno=‘T3025’
查询从广州到西安的所有列车的详细信息
Select*
from Train
where Bstation=’广州’and Estation=‘西安’
2、退票系统:
CREATE TRIGGER tri_ST
on ST for update as [email protected] char(5)
declare @sun = (select sun from updata)
begin
updata st set Samount-1
where Sno = ‘235120’and Tno = ‘T3025’and Tname = ‘软卧’
END
3、购票系统
create trigger tri_ST2
on ST
for update
as
declare @sun char(5)
set @sun = (select sun from updated)
begin
update st set Samount = Samount +1 where Sno=‘326900’ and Tno=‘K512’ and Tname=‘硬座’
end