Different plugin for the database in a flutter
What is Database
A database is an organized collection of structured information, or data, typically stored electronically in a computer system. A database is usually controlled by a database management system (DBMS).
We can organize data into rows, columns, tables, and indexes. It makes data management easy
CRUD is a synonym for the most common database interactions and it stands for Create, Read, Update, and Delete
SQL/Relational Database
SQL is a Structured Query Language, which is a computer language for storing, manipulating, retrieving data stored in a relational database.
NoSQL JSON database can store and retrieve data using literally “no SQL.” Or you can combine the flexibility of JSON with the power of SQL for the best of both worlds. Consequently, NoSQL databases are built to be flexible, scalable, and capable of rapidly responding to the data management demands of modern businesses
NoSQL/Non-Relational Database
A non-relational database stores data in a non-tabular form, and tends to be more flexible than the traditional, SQL-based, relational database structures. It does not follow the relational model provided by traditional relational database management systems. non-relational databases might be based on data structures like documents. A document can be highly detailed while containing a range of different types of information in different formats.
SQL/Relational Database Plugin Lists
Sqflite
Floor
Drift
NoSQL/Non-Relational Database Plugin Lists
Hive
Objectbox
Firebase
Sharedpreference
Sqflite :
SQLite plugin for Flutter. Supports iOS, Android, and MacOS.
- Support transactions and batches
- Automatic version management during open
- Helpers for insert/query/update/delete queries
- DB operation executed in a background thread on iOS and Android
Let’s look official Sqflite plugin : https://pub.dev/packages/sqflite
Floor :
Floor provides a neat SQLite abstraction for your Flutter applications inspired by the Room persistence library. It comes with automatic mapping between in-memory objects and database rows while still offering full control of the database with the use of SQL
Let’s look official Floor plugin : https://pub.dev/packages/floor
Drift :
Drift is a reactive persistence library for Flutter and Dart, built on top of sqlite let’s you write queries in both SQL and Dart, providing fluent APIs for both languages. You can filter and order results or use joins to run queries on multiple tables. You can even use complex sql features like WITH
and WINDOW
clauses
Let’s look official Drift plugin : https://pub.dev/packages/drift
Hive :
Hive is a lightweight and blazing fast key-value database written. Hive not only supports primitives, lists and maps but also any Dart object you like. You need to generate a type adapter before you can store objects.
Let’s look official Hive plugin : https://pub.dev/packages/hive
Objectbox :
Super-fast Flutter database for storing and syncing Dart. object links / relationships are built-in .keeps data in sync offline or online, between devices and servers.object links / relationships are built-in
Let’s look official Objectbox plugin : https://pub.dev/packages/objectbox
Firebase :
The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. Store and sync data with our NoSQL cloud database. Data is persisted locally, and even while offline, realtime events continue to fire, giving the end user a responsive experience. When the device regains connection, the Realtime Database synchronizes the local data changes with the remote updates that occurred while the client was offline, merging any conflicts automatically.
Let’s look official firebase link : https://firebase.google.com/docs/database/
Firebase database plugin: https://pub.dev/packages/firebase_database
SharedPreference :
SharedPreferences is what Android and iOS apps use to store simple data in an allocated space. This data exists even when the app is shut down and starts up again; we can still retrieve the value as it was.
The data stored in SharedPreferences can be edited and deleted. SharedPreferences stores the data in a key-value pair
Let’s look official sharedpreference link : https://pub.dev/packages/shared_preferences
Final Result :
If you are writing an app that needs to persist and query large amounts of data on the local device, consider using a database instead of a local file or key-value store. In general, databases provide faster inserts, updates, and queries compared to other local persistence solutions.
I will check one by one plugin and get a final conclusion for that which is better for which kind of applications.