How do I design a database to store properties, selecting attributes by synonyms

后端 未结 2 725
北恋
北恋 2020-11-28 05:37

I am designing a database for a real estate application. It is proving to be more involved than I had anticipated (maybe I am overcomplicating things).

The problems

2条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 06:20

    To handle synonyms you could have many-to-many lookup between a table containing the static list of your property types, and a table containing the synonym. This way one synonym could be mapped to more than one property type.

    For example:

    Table:Property Type
    1 House
    2 Appartment
    3 Large House
    4 Cave
    
    Table:Synonym
    1 house
    2 flat
    3 dwelling
    4 condo
    5 mansion
    
    Table:PropertyType-Synonym
    1 1 (House is a house
    1 3 (House is a dwelling)
    2 2 (Appartment is a flat)
    2 3 (Appartment is a dwelling)
    2 4 (Appartment is a condo)
    3 1 (Large House is a house)
    3 3 (Large House is a dwelling)
    3 5 (Large House is a mansion)
    4 3 (Cave is a dwelling)
    

    For properties, you could utilize a kind of open attribute structure.

    For example:

    Table:Property
    1 Apartment F, Field House Gardens
    2 123 Alphabet Street, NumberTown
    
    Table:Attribute
    1 Is ground floor?
    2 Number of bedrooms
    3 Has garden?
    
    Table:Property-Attribute-Values
    1 1 No
    1 2 2
    1 3 Yes
    2 2 5 
    2 3 Yes
    

    Hope this helps

提交回复
热议问题