drop table if exists Cunstomer;
drop table if exists CreditCard;
drop table if exists Hotel;
drop table if exists Room;
create table CreditCard
(
cardID longtext not null,
password char(20),
constraint PK_CREDITCARD primary key (cardID)
);
create table Cunstomer
(
account longtext,
fullname longtext,
email longtext,
hotelID longtext,
constraint PK_CUNSTOMER primary key (account)
);
create table Hotel
(
hotelID int not null
name longtext not null,
location int not null
star int not null
constraint PK_HOTEL primary key (room)
);
create table Room
(
roomID int not null
type longtext not null
price float not null
isAvailable boolean not null
constraint PK_ROOM primary key(roomID)
);
alter table Customer add constraint FK_REFERENCE1 foreign key (hotelID)
references hotel (hotelID) on delete restrict on update restrict;
alter table creditCard add constraint FK_REFERENCE2 foreign key (account)
references Customer (account) on delete restrict on update restrict;
alter table room add constraint FK_REFERENCE3 foreign key (hotelID)
references hotel (hotelID) on delete restrict on update restrict;
alter table room add constraint FK_REFERENCE4 foreign key (account)
references Customer (account) on delete restrict on delete restrict;
- 简单叙说数据库逻辑模型与领域模型的异同:
- 相同点:抽象概念,将需求抽象为可视化的概念关系
- 不同点:领域模型是对领域内概念类或现实世界对象的一种抽象的可视化表示,主要关注现实世界行为、对象和各种概念,挖掘问题域中核心的概念,并建立领域概念之间的关系;而逻辑模型则是领域模型的进一步细化,需要摒弃与具体实现无关的概念以及将需要的概念进一步细化成数据库、类对象等细节