-
Notifications
You must be signed in to change notification settings - Fork 2
A. Should you use NDatabase ?
NDatabase's greatest strength is its ability to quickly create and operate data models without the need for SQL queries. It’s database-agnostic, meaning it works seamlessly with SQL databases, MongoDB, and more. However, it sacrifices some of the fine-grained control found in traditional relational databases.
NDatabase is an indexed key-value store. Let’s dive into the characteristics of a key-value store and explore how NDatabase indexes it!
A key-value store functions similarly to a Map
: you can store a data object using a key and access that data directly in O(1) time. Key-value stores offer unique advantages and disadvantages, so it’s essential to choose the right solution for your project's requirements.
Advantages:
The main advantage of a key-value store is rapid development. With NDatabase, you only need to create a class that extends NEntity
to handle your database management. For instance, on my own server, where I needed to develop multiple plugins quickly, configuring and setting up a relational database would consume too much time. NDatabase allowed me to streamline this process.
Disadvantages:
One of the drawbacks of a key-value store is the lack of support for value-based querying. Typically, this would require retrieving the entire data set and filtering values manually, which is inefficient. However, NDatabase introduces a special mechanism to index your key-value store, enabling efficient queries on value properties.
Read more about Indexing Key-Value Stores and NQuery.
For large projects that require a relational database with complex queries, an ORM like Hibernate may be a better choice, although it requires more development time and maintenance.
In summary, the decision to use a key-value store like NDatabase depends on your need for complex queries. If you require indexing on a specific field, you can create an additional key-value store using that field’s value as the key.