# Multiple cardinality property

How to set a property or an edge for multiple cardinality.

Multiple cardinality allows a property to stored multiple values within a single key, or multiple edges with the same edge label to connect two vertices.

## Procedure

Multiple cardinality property

• Create schema for a multiple cardinality property `item_mult` and create two vertices, each of which has two items listed for the defined property:
``````schema.propertyKey('item_mult').Text().multiple().ifNotExists().create()
schema.vertexLabel('fridgeItem_multiple').properties('item_mult').ifNotExists().create()
graph.addVertex(label, 'fridgeItem_multiple','name', 'item2', 'item_mult',['yogurt','Greek yogurt'], 'item_mult', ['key lime yogurt'])
g.V().hasLabel('fridgeItem_multiple').valueMap()``````
Because `item_mult` is defined with multiple cardinality, any number of key value insertions can be made, even using two lists to insert the values. Note that all values are stored in a single list.
``````==>{item_mult=[cheddar cheese, cheese], name=[item1]}
==>{item_mult=[Greek yogurt, key lime yogurt, yogurt], name=[item2]}``````
• Explore the inserted data further:
``g.V().has('fridgeItem_multiple', 'name', 'item2').values('item_mult')``
``````==>Greek yogurt
==>key lime yogurt
==>yogurt``````
This output makes it clear that each entry in the list is a separately stored value.
• Check for a single list item, specifying a particular value:
``````g.V().hasLabel('fridgeItem_multiple').has('item_mult', 'Greek yogurt').valueMap()
``````
``==>{item_mult=[Greek yogurt, key lime yogurt, yogurt], name=[item2]}``

Multiple cardinality edge

• Create schema for a multiple cardinality edge:
``````// SCHEMA
// PROPERTIES
schema.propertyKey('author').Text().single().create()
schema.propertyKey('city').Text().single().create()
schema.propertyKey('dateStart').Text().single().create()
schema.propertyKey('dateEnd').Text().single().create()
// VERTEX LABELS
schema.vertexLabel('author').properties('author').create()
schema.vertexLabel('city').properties('city').create()
// EDGE LABELS
schema.edgeLabel('livedIn').multiple().connection('author','city').create()
Note that the edge label `livedIn` is defined with multi-cardinality. The sample data loaded with graphloader is:
``````author|city|dateStart|dateEnd