What types of data are supported in Memgraph? - graph-databases

What data types are supported in Memgraph? Is there a difference between node and relationship types? Do I need to define data type in similar way that you define variable types in programing languages?

Memgraph stores all of the data in nodes and relationships. There are some important differences when it comes to them:
Nodes can have labels that are used to label or group nodes. A label is of the type String, and each node can have none or multiple labels. Labels can be changed at any time.
Relationships have a type, also represented in the form of a String. Unlike nodes, relationships must have exactly one relationship type and once it is set upon creation, it can never be modified again.
Nodes and relationships can store various properties. Property names are represented as text, while values can be of different types.
Each property can store a single value, and it is not possible to have multiple properties with the same name on a single graph element. But, the same property names can be found across multiple graph elements.
There are no restrictions on the number of properties that can be stored in a single graph element. The only restriction is that the values must be of the supported types.
This are supported data types in Memgraph:
Null - Property has no value, which is the same as if the property doesn't exist.
String - Character string (text).
Boolean - Boolean value, either true or false.
Integer - Integer number.
Float - Floating-point number (real number).
List - List containing any number of property values of any supported type under a single property name.
Map - Mapping of string keys to values of any supported type.
Duration - Period of time.
Date - Date with year, month, and day.
LocalTime - Time without the time zone.
LocalDateTime - Date and time without the time zone.

Related

Index a large number of fields with unit in solr

I have a large number of fields, which I need to use as facets. So I need to index these fields in SOLR.
Now, these fields support multiple units, and the user may enter value for it in any supported unit. For instance, "distance" is a field with supported units "km, miles, m". User might enter a distance as 10m or 5km
For sorting a field, I would like to convert all its values to a base unit, and sort on the converted values. However, for general display as well as filtering results, I need the raw/unconverted values.
What would be the best indexing approach in this case? I am trying to avoid indexing both converted and unconverted values due to the large number of fields.
You do not need to index both values. In your schema.xml, configure the field with the converted base values as indexed and stored, then configure a second field for the raw display values to be stored but not indexed. As you have to convert the user input to your base unit for sorting anyway, you can use it too for searching on the base unit field.
If you use the parameter fl to control the fields given back to you from Solr, be sure to include the field with the raw values.

storing two classes in a data stucture at once in EIFFEL

I am making a clinic and I need to make a object that stores two medicines at once. The interaction object means MEDICATION_1 is interacting with MEDICATION_2
However the following code is not correct because it does not meet the generic parameter
ERROR: VICG: Actual generic parameter does not conform to constraint.
code:
interaction: HASH_TABLE[MEDICATION, MEDICATION]
HASH_TABLE allows associating objects of one type with objects of another (or the same) type. The first parameter to HASH_TABLE is a value and the second one is a key. Therefore one can keep at most one value for the same key. If this suits your needs, the type of keys has to be HASHABLE. This type defines a function hash_code that computes an integer value for an object. All basic types and STRING are HASHABLE, so you can rely on the existing implementations to compute hash_code for MEDICATION objects. For example, if a medication has a unique name, it makes sense to define is as follows:
class MEDICATION inherit HASHABLE ... feature ...
name: STRING
...
hash_code: INTEGER
do
Result := name.hash_code
end
end

What is the difference between array and enum in C ?

I find enum to be similar to an array,with the elements in it being numbered from 0. So what is the difference between an array and enum?
An Enum is basically a group of named constants.
It is an alternative to numbered flag parameters.
(It also doesn't have to be numbered from zero, you can specify the numbering.)
An Enum could be days of the week for example.
A Enum could departments in a company: eg SALES, BILLING, HR ...
A array is a sequence of memory locations. It is a collection. Each element in that collection is indexed by a number. So using that number you can retrieve the value stored at that location. Much like the page number in a book lets you look up the content of that page, the index on an array lets you look up the value stored at that location.
For example, if your company had numbered physical mail boxes for each department (starting from zero):
and you were creating some very simple software to let users log in to check how many letters they had uncollected,
you might choose to store them in an Array of Ints. Where the index is the mail box number, and the value is the number of letters in the box.
Then for ease of programming, you might choose define the departments as Enums (as described before) such that you could index of department name. But that would be getting more advanced.
You may be confusing Enum, with Enumerable which is a term used in some languages to describe any collection type which can be iterated though in sequence (Eg IEnumerable in C#). This term is not often used in C. It is not in anyway the same at all as Enum.
Array is a variable that can contain multiple elements with index starting from 0 whereas enum is an user defined datatype that contains a list of members for which an integer constant is assigned starting from 0. in case of enum the numbers starting from 0 are not indexes whereas in case of an array they are indexes. Also in case of enum you can assign your own constant values to the members that may or may not start from 0 and may or may not be in a sequence.
The main difference is that an array is a value and an enum is a type. And One main difference we can say that an array is a collection of other values (that is it contains other values, you can iterate through them or access individual ones by index), whereas an enum value is simply one atomic value. It doesn't contain any other values.
Both of them are totally different. Array is a value and enum is a type. array is a collection of different values whereas enum value is simply one value.
Array is used to iterate among various values using index whereas enum is assigned some atomic value and iterated so that we can easily iterate the type.
Array's value are assigned by using = operator 'eg. int a[4]={1,2,3,4}' and enum is the user defined data type and it is assigned like
enum days{sun,mon,tue,wed,thr,fri,sat}

Data representation issue on AppEngine Datastore Object

Structure of Data:
2-D string array of column length 3.
Eg. {["One","Two","Three"],["One","Two","Three"],["One","Two","Three"],...}
Datatypes tried & did not work:
String[][3]
ArrayList<String[3]>
How this data be represented , if not by above Datatypes ?
If you're using the com.google.appengine.api.datastore API, entity properties must be of one of the datastore native types, or a Collection of values of a datastore native type (or types). A single property value can't represent a two-dimensional list without serialization, nor can multiple values for a single property name (the Collection case).
If you can serialize, then that's a potential answer. If you have requirements for indexing values in your array for queries, then you'll need to describe those to figure out an answer. For example, entries in the array could be separate entities, each with a "first", "second", and "third" property; the main entity has a List of Keys.

Ensuring the right kind of operations on the right types

I want to write a program to load a key-value store with lots of random data of random types. Assuming the key-value store supports three types ( strings, lists and sets ) there are operations that are valid for a set (say, union) that are not valid for strings.
#define SUBSTR 0 // substring, only on strings
#define SEARCH 1 // search, only on strings
#define PUSH 3 // only on lists
#define ADD 4 // only on sets
#define UNION 5 // only on sets
I am populating a table with random operations but want to ensure that those operations are executed on the key of the proper type. For example, ensuring that union operations are always executed on keys of type set.
int optab[100];
optab[0] = ADD
optab[1] = SUBSTR
.
.
.
optab[99] = UNION
For each operation to be performed, I could record the type of each key locally at the time the key is first created in my program or keep traversing the keyspace till I find the key of the right type. But I don't want to do either.
With the first option the size of the structure used to maintain the details grows as new keys (and types) are added. And with the second option the time needed to find the right key for the type grows as keys (and types) are added.
Is there a clever way to match types and operations properly without depending on the size of keyspace or the number of types supported?
I am hoping that given an operation I could generate a random key name (like, key90876) with 90876 being the random part that would be of the right type.
If each operation is valid for only one type, you wouldn't require any extra space or time - you just load the keys into different lists based on their type and each operation would work on the corresponding list.
If the same operation may apply to more than one type, then there isn't any specifically "clever" way to do this. It's a matter of space-time tradeoff and you should choose whichever method suits you best. Randomly picking keys until it matches an operation will work, but there is no guarantee as to how many tries you need before you get the right type of key.

Resources