Course contentsShow
← Computer Science
Lesson 1748 of 2,87239. NoSQL and Modern DatabasesFree lesson

Nodes and Properties

Defining nodes as entities with labels and key-value properties, modeling domain objects in graph structure.

Nodes and Properties in Graph Databases

You'll learn how graph databases use nodes and properties to model real-world entities as a flexible, interconnected data structure.

What Are Nodes?

In a graph database, a node represents a single entity or object from your domain—think of it as a "thing" you care about. Each node can have:

  • Labels: Categories that classify the node (like "Person", "Product", "City")
  • Properties: Key-value pairs that store the node's attributes

This is fundamentally different from relational tables where you define rigid columns upfront. Nodes are flexible containers that hold whatever properties make sense for that specific entity.

Modeling with Nodes and Properties

Imagine modeling a social network. A node might represent a user:

  • Label: Person
  • Properties: { name: "Alice", age: 30, email: "alice@example.com" }

Another node for a company:

  • Label: Company
  • Properties: { name: "TechCorp", founded: 2010, industry: "Software" }

Notice how different node types naturally have different properties—no need to force both into the same table structure with nullable columns. Each node is self-describing.

Why This Matters

The node-property model mirrors how we naturally think about objects. You're modeling your domain directly rather than decomposing it into normalized tables. Two Person nodes can even have different properties if needed—one might have a phone_number property while another doesn't, offering schema flexibility.

Properties use key-value pairs, making them intuitive: the key is always a string, and the value can be strings, numbers, booleans, or even arrays.

Key Takeaway:
Nodes are labeled entities with flexible key-value properties that model real-world objects directly, enabling intuitive graph structures that mirror your domain without rigid table schemas.