What data type should the unique IDs be in Neo4j? - neo4j

I'm about to LOAD some random data into Neo4j. Documentation says that the IDs must be unique. Does the data type of unique identifier matter? For e.g. can I have a unique string as an identifier instead of a (integer) number?

Yes, you can have unique Strings instead on numbers! afaik, any valid data type, even Point

Related

Unique identifier for all fix messages related to a sinqle request in quickfix

We need to get a unique identifier for all related fix messages in quickfixj.
scenario: if B lies between A and C and forwards fix messages from A to C and vice versa, we need to get a unique Id for all related messages to cache them in B.
Is there a uniqueId for all fix messages as mentioned above? if yes, does getting that unique identifier same (eg: message.getString(int field)) for all message types, or getting it depends on message type?
Do you mean a unique identifier per Order, for example? If yes, then that would be 11/ClOrdID for a NewOrderSingle (and some other message types). But you'll have other identifiers for other message types, e.g. quotes, market data snapshots, ...
There is no global unique identifier per se, so you would need to make one up. For example a concatenation of SenderCompID and MsgSeqNum and SendingTime should be unique. If you are sure that you will not reset the sequence number intra-day you could probably even leave out the SendingTime.

Redis get keys for sorted sets where at least one member has score less than N

I Have multiple sorted sets in my redis. The keys of them have the following pattern:
user:{userId}:data
where userId is the actual value.
Each member of the corresponding set has score equals to the timestamp when it was added.
Now I'm trying to figure out how can I retrieve redis keys for those sorted sets where at least one member was added before a certain timestamp (meaning that at least one member has score less than given timestamp in millis).
I can retrieve all the keys by pattern:
KEYS 'user:*:data'
Actually, I can check required condition for one key using command:
ZRANGEBYSCORE user:{userId}:data -inf {timestamp}
and then checking size of returned data
But do I have any way (either one-line, or piping commands, or with Lua script) to get only those keys of sorted sets where at least one of the elements has lower score than given?
I'd avoid KEYS, or SCAN, if this query is important (i.e. needs to return fast). Instead, keep another sorted sets with the earliest timestamp each user has, and query it.

Generating a unique numeric id in neo4j

I am aware of the UUID module but as far as I know that module does not allow you to use only numeric characters. We expect our database to have millions of records and a number search is faster than a character search.
Is there a better way of generating a unique ID for each node?
If you tell me to use UUID, in traversing a graph database with millions and a possible billion of nodes how badly would the performance suffer?
The property type used for a single lookup will not differ by using numbers or uuid strings, it will always remain an O(1)+1 operation (if you back it up by a unique constraint).
On another side, the uuid module benefit recently from a sequential ID generator that you can choose instead of the default uuid generator :
https://github.com/graphaware/neo4j-uuid/blob/master/README.md#specifying-the-generator-through-configuration

Retrieving statement in Jena by its unique ID

I'm building a REST API which will serve information about statements stored in my Jena TDB.
It would be great if each statement has its unique ID so I can use this ID in GET request to retrieve information about particular statement. Is there something like that in Jena?
I know I can retrieve statement(s) by providing appropriate subject/predicate/object identifiers to model.listStatements method, but it would be quite ugly to add these parameters to API GET requests.
In RDF, a triple is defined by its subject, object and predicate. If you have two triples with the same S/P/O, it is really the same triple (value-equality, not instance equality). An RDF graph is a set of triples; if you add a triple twice, the set has only one instance. There is no triple id concept in RDF, and there isn't internally in TDB.
So you could use unique identifiers, say a string of length 4, for every S, every P and every O. Just save them all as key/value (id/resource, id/property) pairs. Then you will have a string of length 12 as unique identifier of your statement.
Even if a statements is deleted and added again, leading to a different id when tagging every statement with an id, this method will yield the same statement every time.

Predicate com CAST

Accessing database .sqlite by sql query normally, I can use the function CAST('column' as decimal).
By NSPredicate, using CoreData, how to make this CAST? I have one column of type String and I need make one cast to decimal type for compare with other decimal number.
You should not care about how SQLite stores your object graph. In fact, SQLite is pretty liberal about types, so what you should really rely on is the type you specified in your model and your model subclasses.
If your column is a String use this:
NSPredicate(format: "column = %#", "\(decimal)")
You can then process the result further if you need a number rather than a string.

Resources