How to store meta-data on columns

前端 未结 9 582
死守一世寂寞
死守一世寂寞 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:22

    Here's another idea...feel free to punch holes in it :)

    Table: Movie
    Columns: MovieId|Movie|Director|LeadMale|LeadFemale|Villain
    
    Table: MovieSource
    Columns: MovieSourceId|MovieId|MovieRoleId|Source|Journalist
    
    Table: MovieRole
    Columns: MovieRoleId|MovieRole
    Values: 1|Director, 2|LeadMale, 3|LeadFemale, 4|Villain
    

    What I'm thinking is that the columns in the movie table could be of different types (in your example, they are all strings/varchars, but they could be, say, numerical or date information that also has a source).

    The column types for the source data, however, probably wouldn't vary as a function of the column types of the movie data, so you could use more of an EAV system for the source without losing the integrity of your data.

    The MovieRole table allows you to explicitly enumerate the roles so you can create a sure linkage between the source and a given cell of the movie table.

    -Dan

提交回复
热议问题