drop table if exists `Card`;
drop table if exists `Computer`;
drop table if exists `Record`;
create table `Card`(
`ID` int not null auto_increment,
`CardID` char(8) not null,
`pwd` varchar(16) not null,
`balance` float not null,
`name` varchar(16) not null,
primary key(`ID`)
)engine=myisam;
create table `Computer`(
`ID` int not null auto_increment,
`ComputerID` char(3) not null,
`CardID` char(8) not null,
`isUse` bit(1) not null default 0,
`remark` varchar(300),
primary key(`ID`),
foreign key(`CardID`) references `Card`(`CardID`)
)engine=myisam;
create table `Record`(
`ID` int not null auto_increment,
`CardID` char(8) not null,
`ComputerID` char(8) not null,
`BeginTime` datetime ,
`EndTime` datetime,
primary key(`ID`),
foreign key(`ComputerID`) references `Computer`(`ComputerID`),
foreign key(`CardID`) references `Card`(`CardID`)
)engine=myisam;
insert into `Card`(`CardID`,`pwd`,`balance`,`name`) Values('00000001','123456',15.3,'purana');
insert into `Card`(`CardID`,`pwd`,`balance`,`name`) Values('00000002','756321',15.3,'jiajia');
insert into `Card`(`CardID`,`pwd`,`balance`,`name`) Values('00000003','12345',15.3,'jiadf');
insert into `Card`(`CardID`,`pwd`,`balance`,`name`) Values('00000004','75145',15.3,'mysql');
insert into `Computer`(`ComputerID`,`CardID`,`isUse`) Values('001','123456',1);
insert into `Computer`(`ComputerID`,`CardID`,`isUse`) Values('002','756321',1);
insert into `Computer`(`ComputerID`,`CardID`,`isUse`) Values('003','12345',1);
insert into `Computer`(`ComputerID`,`CardID`,`isUse`) Values('015','75145',1);
insert into `Record`(`CardID`,`ComputerID`,`BeginTime`,`EndTime`) Values('00000001','001','2007-09-09 10:15:12','2007-09-09 11:01:02');
insert into `Record`(`CardID`,`ComputerID`,`BeginTime`,`EndTime`) Values('00000002','002','2007-09-09 15:35:33','2007-09-09 16:22:33');
insert into `Record`(`CardID`,`ComputerID`,`BeginTime`,`EndTime`) Values('00000003','003','2007-09-09 20:14:01','2007-09-10 01:33:02');
insert into `Record`(`CardID`,`ComputerID`,`BeginTime`,`EndTime`) Values('00000004','015','2007-09-10 01:42:10','2007-09-10 22:01:02');