I just wondering why do we have the procedures some with dbms. and db. (for example
CALL dbms.components() and
CALL db.constraints() ), what is the difference between dbms and db.
This may seems silly question, but somehow i need to understand the logic and purpose of it.
Please help me understanding this.
To answer this, I'm speaking specifically about 4.0 procedures, which you can find here: https://neo4j.com/docs/operations-manual/current/reference/procedures/
DBMS = database management system. An entire running instance of Neo4j is a DBMS
DB = database. That would be an individual graph / collection of nodes/edges.
Neo4j just went to 4.0, which is critical to this answer because previously, you could only have one big graph in a Neo4j 3.5 system. And so arguably the lines were blurred a bit because 1 DBMS always had 1 DB. Under Neo4j 4.0, you always have multiple databases by default. At a minimum, system and neo4j. So with Neo4j 4.0, you have no less than 1 DBMS and 2 DBs.
Now let's look at individual procedure naming.
dbms.components()lists software components such as how authorization is handled for, that work for the entire DBMS. So it makes sense that it's in the DBMS "namespace"
db.constraints()lists the constraints that apply to a single graph. Suppose you did
CREATE DATABASE foo;and then later
CREATE DATABASE bar;and then you created some constraints on
foo. Well -- those would be DB-specific. If you then switched to
db.constraints()you'd get nothing -- and should get nothing, because those constraints are on the other database. So the
dbscoping makes sense here too.
If you go through other procedures, you should find that they're named along similar lines, for similar reasons.