小编Ait*_*tor的帖子

查询匹配多行?

我们的系统中有下表

对象

object_id    object_description
    1             "Car"
    2             "Person"
Run Code Online (Sandbox Code Playgroud)

属性

attribute_id    attribute_name
     1             "hair_color"
     2             "height"
     3             "number_of_doors"
     4             "engine_size"
Run Code Online (Sandbox Code Playgroud)

attribute_value

attribute_id    attribute_value_id    value
    1                1                "black"
    1                2                "blonde"
    2                1                "more than 1 meter"
    2                2                "less than 1 meter"
    3                1                "5 doors"
    3                2                "3 doors"
    4                1                "more than 1.9"
    4                2                "less than 1.9"
Run Code Online (Sandbox Code Playgroud)

object_attribute

object_id    attribute_id    attribute_value_id
    1            3                1 -- Car, number of doors,5
    1            3                2 -- Car, …
Run Code Online (Sandbox Code Playgroud)

sql postgresql

5
推荐指数
1
解决办法
302
查看次数

Which of these DB designs is better?

I'm trying to understand some concepts of DB desing.

I have three tables:

Movies (id,title)
1 - The godfather
2 - Matrix


Attribute (id,name)
1 - Country
2 - Type

Attribute Value(attribute_id,id,value)

1,1,USA
1,2,Japan
2,1,Thriller
2,2,Comedy
Run Code Online (Sandbox Code Playgroud)

and I would like to link movies with one and just one attribute and with one attribute value

IE: Godfather, Country: USA, Type: Crime

I'm trying to find out which of the next is the best solution for linking attributes to a movie. I …

sql database

5
推荐指数
1
解决办法
331
查看次数

标签 统计

sql ×2

database ×1

postgresql ×1