MonsterDB – Database Commands

query language

It is no secret that monsterDB query language is based upon the syntax that is used by MongoDB, this doesn’t mean we use mongoDB, we are built from the ground up as a pure Java engine.

Database Commands

A monsterDB database stores many collections, each database acts independently and does not see the contents of other databases. If you drop a a database it will drop all the collections within it. Collections in MonsterDB take two distinct forms, but they act very similar to each other, there are normal collections and fuzzy collections.

Normal Collections

Normal Collections store data in optimised way for standard data, once a collection is created in the normal way, it cannot be converted to a fuzzy collection and vice versa. Normal collections can have any number of unique or non-unique indexes that can be composite keyed or single keyed. The optimiser will not consider any fuzzy aspects in its work to speed up your query.  

Fuzzy Collections

 However a fuzzy collection can be used as a normal collection if need be, that said fuzzy collections have a considerable indexing overhead due to the cost of maintaining bucketed indexes. Fuzzy collections need more metadata to maintain standardisation and indexing. Fuzzy databases also maintain additional data indexing and standardisation indexes within their structure and such will b e larger. Fuzzy collections are inserted/updated as normal, but must be queried using special methods as described.

useCollection

usage from API: void useCollection(collectionName)
usage from CLI: useCollection collectionName
Switches context to this collection, at this point monsterDB will only take note of this for setExplain, but in the future it will be used by the optimiser as a hint for joined collections.

createCollection

usage from API: void createCollection(collectionName)
usage from CLI: db createCollection collectionName

Creates a normal / non fuzzy collection and switches context to this new collection.

createFuzzyCollection

usage from API: void createFuzzyCollection(collectionName, definition, map)
usage from CLI: db createFuzzyCollection collectionName definitionFile ruleSetMapDirectory

API explanation: Creates a fuzzy collection and switches context to this new collection.
definition refers to a “Document” object that defines the match rules needed for matching as defined in the MARS schema definition here.
The map is a RuleSetMap that contains the definition of commonly used values and translations for example nick names and company legal name types. The RuleSetMap can be read using a convenient factory method as below in java:

RuleSetMap map=RuleSetMap.readMap(mapDir);

Where mapDir is a string containing the full path of the ruleset files, standard ruleset files can be requested from EntityStream or you can build your own as described here.

CLI explanation: Creates a fuzzy collection and switches context to this new collection.
definitionFile refers to a text file name that contained the JSON format schema definition as defined in the MARS schema definition here.
The ruleSetMapDirectory is a location on the server disk that contains the definition of commonly used values and translations for example nick names and company legal name types. Standard ruleset files can be requested from EntityStream or you can build your own as described here.

dropCollection

usage from API: void dropCollection(collectionName)
usage from CLI: db dropCollection collectionName

Drops a collection and removes the file associated with this collection, this is a very destructive command and should be used carefully.

listCollectionNames

usage from API: List listCollectionNames()
usage from CLI: db listCollectionNames

Lists all known collections in the currently used database (in context), it will return a list of Documents each document will contain the name of the collection.

setExplain

usage from API: void setExplain(true|false)
usage from CLI: db setExplain true|false

Sets the debug flag for a collection, similar to the database level setDebug, but will only affect queries that hit the collection in context.