How to store meta-data on columns

前端 未结 9 585
死守一世寂寞
死守一世寂寞 2020-12-28 09:31

Let\'s say you\'re collecting insider info on upcoming superhero movie releases and your main Movie table looks something like this:

Table 1

9条回答
  •  自闭症患者
    2020-12-28 10:24

    Seeing as you only have the two fields for source data (Source and Journalist), I would recommend a meta-data table like this:

    Movie    DirectorSource  DirectorJournalist  LeadingMaleSource  LeadingMaleJournalist ...
    ---------------------------------------------------------------------------------------
    The Tick   Yahoo           Cameron           ...                ...
    

    This will keep the less important source data out of the main table, but the queries will not get complicated and your code will be more readable.

    I would only advise EAV if ...

    • You have more than 3 fields of source meta-data
    • You need to be able to add or change movie fields easily. (changes like 'Villain' to 'Primary Villain' are being done several times per day)

提交回复
热议问题