cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Re: Graph Modeling Issue

OmarHamdy
Node Clone

My queries for "Tag" : one for inserting tag and some queries to retrieve them knowing that every tag has one type of alarm so i expected two possibilities : 

  1. make every tag has all alarms properties "Digital input" Tag properties like "state0" and "state1" and "Analog input" Tag properties like "Alarm LL Value" , "Alarm L Value" , "Alarm H Value" and "Alarm HH Value"
  2. Make alarm node for every type : Tag-[:HAS_DIGITAL_ALARM]->:Digital_alarm                                                                                                 Tag-[:HAS_ANALOG_ALARM]->:Analog_alarm 

every alarm node type with its own properties but the problem will be that i don't have Unique id for every alarm because every node is just about some readings 

 

1 ACCEPTED SOLUTION

If a tag represents some sensor or hardware, then you should be able to assign some unique ID to it, such as asset number, serial number, etc. Can you use a data model as illustrated in the screenshot?  Each tag (piece of hardware) emits sensor readings or alarms if a threshold is reached. Either way, you can capture these events in an 'Alarm' or "Measurement" node, which is linked to the sensor/hardware that generated the data/alarm. Each node has two labels, one representing its generic type, such as Tag or Alarm, and one representing the type, such as Digital or Analog.

Screen Shot 2022-09-07 at 11.11.37 PM.png

View solution in original post

10 REPLIES 10

OmarHamdy
Node Clone

are there any other possibilities ? 

if no , please tell me which approach is better 

if yes , please tell me what are the other possibilities ?

@elaine_rosenber Thank u so much for your cooperation 

I am confused with your use case.  Do you have a bunch of sensors reporting measurements you are trying to track? What does a 'tag' represent, as specific sensor? Is an 'alarm' a measurement, or is an alarm raised under some condition? What kind of information do you want to retrieve from the graph?

Tag is something like sensor, To be accurate tag represents a specific hardware, every tag has alarm readings depending on tag type 

Is it clear now ? 

Alarm readings change uder different conditions, like High pressure alarm (it's a property with specific value)

I want to retrieve every tag alarm reading depending on tag type

If a tag represents some sensor or hardware, then you should be able to assign some unique ID to it, such as asset number, serial number, etc. Can you use a data model as illustrated in the screenshot?  Each tag (piece of hardware) emits sensor readings or alarms if a threshold is reached. Either way, you can capture these events in an 'Alarm' or "Measurement" node, which is linked to the sensor/hardware that generated the data/alarm. Each node has two labels, one representing its generic type, such as Tag or Alarm, and one representing the type, such as Digital or Analog.

Screen Shot 2022-09-07 at 11.11.37 PM.png

Thank you for your great effort 

ameyasoft
Graph Maven

Try this:

MERGE (a:DigitalTag {state0: line.State0, state1: line.State1})
MERGE (b:AnalogTag {alarmLLValue: line.`Alarm LL Value`, alarmLValue: line.`Alarm L Value`, alarmLLValue: line.`Alarm LL Value`, alarmHValue: line.`Alarm H Value`, alarmHHValue: line.`Alarm HH Value`})

Thank u so much 

ameyasoft
Graph Maven

Try this:

LOAD CSV WITH HEADERS FROM 'file:///xxx.csv' AS line

WITH line, line.`I/O Type`   as iType

CALL

{
WITH line, iType
WITH line, iType
WHERE iType contains("Digital")
MERGE (a:DigitalTag {state0: line.State0, state1: line.State1})
//Add your relationship cypher below....
MERGE (b)-[:HAS_DIGITAL_ALARM]->(a)
}

CALL

{
WITH line, iType
WITH line, iType
WHERE iType contains("Analog")
MERGE (b:AnalogTag {alarmLLValue: line.`Alarm LL Value`, alarmLValue: line.`Alarm L Value`, alarmLLValue: line.`Alarm LL Value`, alarmHValue: line.`Alarm H Value`, alarmHHValue: line.`Alarm HH Value`})
//Add your relationship cypher below....
MERGE (b)-[:HAS_ANALOG_ALARM]->(a)
}

Thank u very much