我在非行有两张表格。
- FuelStation (fuel_station_id: int (PK), fuel_station_name: varchar, fuel_brand_id: int(FK))
- FuelBrand (fuel_brand_id: int (PK), fuel_brand_name: varchar)
我们可以看到,两个表格都通过链接。 外国钥匙(燃料_brand_id)
现在,我想设计一个与上述数据模型相对应的物体模型,但我感到困惑的是,从以下两种方法中采用哪种方法:
- Whether to make only one class
FuelStation
and store fuel brand asString
in theFuelStation
class.
页: 1
- Make two classes:
FuelStation
andFuelBrand
. And then associate them with a Many-to-One relationship as one fuel station will have only one fuel brand but one fuel brand can have many fuel stations.
问题1. 哪一种办法更好?
问题2. 每一种做法的利弊是什么?
Upto My Knowledge:
办法2
它使我们的物体模式更加 gr。
就良好设计原则而言,我们的物体-模型必须作为同体-模型的微粒。 方法2遵循这一原则。
办法1
- No need to create a separate object for FuelBrand for every FuelStation