Can we have one attribute with multiple values ​​in an eav project?

I am doing a database project using EAV. I ran into a problem when I try to model an object with an attribute having multiple values?

for instance

Essence

id         | name           | description
--         | ----           | ------------ 
1          | configuration1 | configuration1

Attribute

id         | entityId    | name  | type
--         | --------    | ----  | ----
1          | 1           | att1  | string
2          | 1           | att2  | int
3          | 1           | att3  | List<String>  (How will i model this?)

Value

id        | attributeId    | value
--        | -----------    | -----
1         | 1              | a    
2         | 2              | 1
3         | 3              | b
4         | 3              | c    
5         | 3              | d

Is this the right way to handle a list of values?

Please provide any useful link to simulate this?

Two more questions

1) Is the List type correct? I want to be sure that when one attribute has several values, I will give the type as List

2) How will the database design change if the attribute matches the object? For example, the user has an address. How to handle composite parameters?

It would be great if you could provide me with a crude table view or diagram

thank

Shekhar

+3
1

! multi-value EAV.
, , , ; ().

- ! ( )
, EAV :

  • , , . (BTW, , , ..
  • ( 0 1 , - ).

, EAV , () , , , ..

: ( / ( "" ) )
, [ "sub" -] , ( , ), , .. (...) , "" ", , ; JSON XML-at-large /, , , (, ).

"" (EAV-) " " ( , , , ). "" , .

, , . ( ), , [] , [ , ] , , " " (, , , .

:
, : (, ).
:
 - , , , , [] .
 - , , , "0.75 | Inch" ( <diam>0.75</diam><unit>Inch</unit>).
:
- 3 : , "diamvalue", , "", "Diameter"; - ( -) - : diamvalue unit ( , "", AttributeID "Diameter" ). value "Diameter" [ "" .

, , [ ] , , , . SQL, SQL "Diameter" .

; -)
" ".

Entity 
    id   | name           | description
    --   | ----           | ------------ 
    1    | configuration1 | configuration1

Attribute 
    id   | name      | type     | Required | Repeats | SubAttribIdList
    --   | ----      | ----     | -------- | ------- | ---------------
    1    | att1      | string   | N        | N       | null   (only applicable to composite types)
    2    | att2      | int      | Y        | N       | null
    3    | att3      | string   | Y        | Y       | null
    4    | DiamValue | numeric  | Y        | N       | null
    5    | Unit      | string   | Y        | N       | null
    6    | Diameter  | composite| N        | N       | 4,5

Value
    id  | entityId| attributeId  | ParentAttribId |SeqNr | value     
    --  | --------| -----------  | -------------- |----- | -----
    1   | 1       | 1            | null           | 1    | a    
    2   | 1       | 2            | null           | 1    | 1
    3   | 1       | 3            | null           | 1    | b  (this value and next show show a repeating attribute)
    4   | 1       | 3            | null           | 2    | c    
    5   | 1       | 3            | null           | 3    | d
    6   | 1       | 4            | 6              | 1    | 0.75   (this value and next one shows a composite attribute
    7   | 1       | 5            | 6              | 1    | Inches

:
 - SeqNr ids 6 7 1 . SubAttribIdList. id 6 ( "" ), , , 2, 3 ..
 - 1, NULL, .
 - "" ; , , ( ) .
 - 1 ( ), , . ( ), (, , ).

+6

Source: https://habr.com/ru/post/1737092/


All Articles