酒店管理系统mysql
时间: 2023-09-20 10:04:18 浏览: 73
sql 酒店管理系统
酒店管理系统通常需要使用到 MySQL 数据库来存储和管理数据,包括酒店客房信息、客户信息、预订信息、订单信息等。下面是一个简单的酒店管理系统 MySQL 数据库设计示例:
1. 客户信息表:
CREATE TABLE `customer` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`phone` varchar(20) NOT NULL,
`email` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2. 客房信息表:
CREATE TABLE `room` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`room_number` varchar(20) NOT NULL,
`room_type` varchar(50) NOT NULL,
`price` decimal(10,2) NOT NULL,
`status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:未入住,1:已入住',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3. 预订信息表:
CREATE TABLE `reservation` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11) NOT NULL,
`room_id` int(11) NOT NULL,
`check_in_date` date NOT NULL,
`check_out_date` date NOT NULL,
`status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:未确认,1:已确认',
PRIMARY KEY (`id`),
KEY `fk_reservation_customer` (`customer_id`),
KEY `fk_reservation_room` (`room_id`),
CONSTRAINT `fk_reservation_customer` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_reservation_room` FOREIGN KEY (`room_id`) REFERENCES `room` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4. 订单信息表:
CREATE TABLE `order` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11) NOT NULL,
`room_id` int(11) NOT NULL,
`check_in_date` date NOT NULL,
`check_out_date` date NOT NULL,
`total_price` decimal(10,2) NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_order_customer` (`customer_id`),
KEY `fk_order_room` (`room_id`),
CONSTRAINT `fk_order_customer` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_order_room` FOREIGN KEY (`room_id`) REFERENCES `room` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
这些表可以根据实际需求进行修改和扩展。在实际开发中,还需要写对应的 SQL 语句来完成数据的增删改查等操作。
阅读全文