Graph Databases:
The main components of a property graph database are as follows:
- Node: also known as a vertex in graph theory – the main data element from which graphs are constructed
- Relationship: also known as an edge in graph theory – a link between two nodes. It will have direction and a type. A node without relationships is permitted, a relationship without two nodes is not permitted
- Label: Defines a node category, a node can have more than one
- Property: Enriches a node or relationship, no need for nulls!
Relational Database:
Data is stored in tables within a well-defined schema.
Each row in the table is a discrete entity of data. One of these elements in the row is typically used to define its uniqueness: the primary key. It could be a unique ID or maybe something like a social security number for a person.
We then go through a process called normalization to reduce data repetition. In normalization, we’re moving references, something like an address for a person, into another table. So we get a reference from the row representing the entity to the row representing the address for that person.
If, for example, somebody changes their address, you wouldn’t want multiple versions of that person’s addresses everywhere and have to try and remember all the different instances of where that person’s addresses exist. Normalization makes sure you have one version of the data, so you can make the updates in one place.
What are the differences between a graph database and a relational database?
As we described above, graph databases and relational databases have different ways of storing and retrieving data.
- Data modeling Relational databases are dependent on tables, and use a predefined schema to organize data. Within a relational database, entities are the focus of the data model.
A graph database on the other hand, stores data as nodes and edges. The data model allows for a flexible schema and the ability to easily traverse and query relationships, making it well suited for data that has complex relationships. Indeed, relationships are the star of the show in a graph data model.
Query language
Query languages for the two types of databases also differ. Relational databases use SQL (Structured Query Language) to query the data, while graph databases use a specific query language such as Gremlin or Cypher. Graph query languages tend to be faster to write than SQL.Performance
Graph databases offer some key benefits over relational databases depending on your use case. Because of their flexible data model, they are more scalable than relational databases. Their more effective indexing also means they tend to offer a better performance with faster querying.
References:
Apache AGE
Apache AGE Github
Top comments (0)