说我正在建立一种CMS。我想存储不同类型的属性,例如房屋,公寓,建筑物,停车场等。
我可能事先不知道所有属性类型,也不知道某个属性类型可以具有的所有属性。因此,我希望用户能够通过Web UI添加自己的类型和属性。
我想到了这个,但是我觉得这是错误的:
有意义吗?有更好的方法吗?
示例数据:
TaxonType +------+-----------------+ | id | name | +------+-----------------+ | 1 | 'Property type' | +------+-----------------+ Taxon +----+---------------------+------------+--------+ | id | taxon | taxon_type | parent | +----+---------------------+------------+--------+ | 1 | 'Property' | 1 | null | | 2 | 'House' | 1 | 1 | | 3 | 'Condominium house' | 1 | 2 | +----+---------------------+------------+--------+ Attribute +----+------------------+ | id | attribute | +----+------------------+ | 1 | 'Surface area' | | 2 | 'Parking spaces' | | 3 | 'Pool' | +----+------------------+ Unit +----+----------------+--------+ | id | unit | symbol | +----+----------------+--------+ | 1 | 'Square Metre' | 'm2' | +----+----------------+--------+ Taxon_Attribute +-------+-------------+ | taxon | attribute | +-------+-------------+ | 1 | 1 | | 1 | 2 | | 2 | 3 | +-------+-------------+ Object +----+ | id | +----+ | 1 | +----+ Taxonomy +-------+--------+ | taxon | object | +-------+--------+ | 3 | 1 | +-------+--------+ AttributeValue +----+-------+------------------+-----------+--------+ | id | value | measurement_unit | attribute | object | +----+-------+------------------+-----------+--------+ | 1 | '200' | 1 | 1 | 1 | | 2 | '3' | null | 2 | 1 | | 3 | 'yes' | null | 3 | 1 | +---+--------+------------------+-----------+--------+