SQL 酒店实体关系图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26066311/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 02:41:49  来源:igfitidea点击:

Entity Relationship Diagram for Hotel

sqlentity-frameworkdatabase-designentity-relationshiperd

提问by Marilee

I need to create an ERD for a hotel, the question reads as follows:

我需要为酒店创建一个 ERD,问题如下:

"The owner of a set of hotels would like to have a hotel management system built for his or her hotels. The hotels are located in major cities and tourist attraction areas of South Africa. In each hotel, employees are hired to perform various duties. In each hotel, guests make reservations for rooms of their choice, and they are billed according to the type of room they have reserved. Given the business scenario above, please draw an entity relationship diagram indicating all entities and relationships (cardinality)."

一套酒店的业主希望为他或她的酒店建立一套酒店管理系统。这些酒店位于南非的主要城市和旅游景点区。在每家酒店中,员工都被雇佣来履行各种职责。在每家酒店,客人预订自己选择的房间,并根据预订的房间类型进行计费。鉴于上述业务场景,请绘制一个实体关系图,表示所有实体和关系(基数)。

This is what I have created:

这是我创建的:

enter image description here

在此处输入图片说明

My Questions

我的问题

  • if Employee_ID is a foreign_key in Hotel, will it be a foreign_key in Employees table aswell or does it just change to a Primary key?

  • Is it correct / okay to add Hotel_code, and Room_ID in the Reservation table? Is Hotel_CODE a foreign key in RESERVATION table?

  • Is the overall design of the ERD correct or to an acceptable level including keys and attributes

  • 如果Employee_ID 是Hotel 中的foreign_key,它是否也是Employees 表中的foreign_key 还是只是更改为主键?

  • 在预订表中添加 Hotel_code 和 Room_ID 是否正确/可以?Hotel_CODE 是 RESERVATION 表中的外键吗?

  • ERD 的整体设计是否正确或达到可接受的水平,包括键和属性

If someone could skim this over for me it would be much appreciated

如果有人可以帮我浏览一下,我将不胜感激

回答by schudel

Take this with a grain of salt as I'm not 100% sure:

因为我不是 100% 确定,所以请稍加保留:

  • The Employee shoud have a foreign key to the Hotel_code (assuming one employee does not work for multiple hotels)
  • The hotel does not have a foreign key to the employee
  • The reservation should have a foreign key to the hotel_code
  • The Guest does not need a foreign key to the reservation
  • Guest_Id should not be part of reservations PK
  • the bill should have a foreign key to the reservation instead of to the guest
  • the reservation could have additional information about the duration of the stay
  • the room does not need a guest_id and res_nr
  • 员工应该有一个指向 Hotel_code 的外键(假设一名员工不在多家酒店工作)
  • 酒店没有员工的外键
  • 预订应该有一个指向hotel_code的外键
  • 客人预订时不需要外键
  • Guest_Id 不应成为预订 PK 的一部分
  • 账单应该有预订的外键,而不是客人
  • 预订可能包含有关逗留时间的其他信息
  • 房间不需要guest_id和res_nr