【发布时间】:2021-12-24 21:05:04
【问题描述】:
我正在尝试根据以下信息设计数据库:
房东记录了每个房产的以下数据:
-Eircode
-Capacity of property i.e. number of tenants it can hold
-Number of tenants currently renting this property
-Cost of rental per tenant per calendar month
房东存储每个租户的以下信息:
-Name
-Email
-Phone number
我对“每个租户的租金成本”行感到困惑,该行放置在哪个表中以及如何建立连接。任何帮助将不胜感激。
以下是我目前得到的:
CREATE TABLE property (
Eircode int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
MaxCapacity int(10) NOT NULL
NumberOfTenants int(10) NOT NULL
CostOfRental int(10) NOT NULL
);
CREATE TABLE tenant (
tenantID int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
tenantName varchar(30) NOT NULL
tenantEmail varchar(30) NOT NULL
tenantPhone varchar(30) NOT NULL
);
【问题讨论】:
-
公寓需要第三张桌子,因为我假设每个物业可以有 1 个或多个公寓。 CostOfRental 将成为该表的一部分。
-
勾勒出您需要的
SELECTs。这将帮助您设计架构。
标签: mysql sql database database-design