You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/topics/schema.mdx
+17-3Lines changed: 17 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,14 +25,28 @@ To help with the development process of a schema definition file, you can levera
25
25
26
26
## Schema definition
27
27
28
-
### Namespace, Node, Attributes, Relationships, and Generics
28
+
### Node, Attributes, Relationships, and Generics
29
29
30
30
The schema is composed of 4 primary types of objects: `Nodes`- that are themselves composed of `Attributes` and `Relationships` and finally `Generics`.
31
31
32
-
- A `Node` in Infrahub represents a `Model`.
32
+
- A `Node` in Infrahub represents a `Model`. Nodes are instances of a specific object within your infrastructure. Nodes have attributes that define specific values, such as text or numbers, and relationships that link them to other nodes.
33
33
- An `Attribute` represents a direct value associated with a `Node` like a `Text`, a `Number` etc ...
34
34
- A `Relationship` represents a link between 2 `Node`, a `Relationship` can be of cardinality `one` or `many`.
35
-
- A `Generic` can be used to share some attributes between multiple `Node`, if you're familiar with programming concept, it's close to class inheritance.
35
+
- A `Generic` can be used to share attributes and relationships between different types of `Node`s. They can connect multiple types of nodes to the same relationship or define attributes and relationships on a specific list of nodes. Generics are similar to class inheritance in programming languages like Java or Python.
36
+
37
+
### Nodes vs. Generics
38
+
39
+
Use a `Node` when you need to represent a concrete object in your infrastructure model with specific attributes and relationships.
40
+
41
+
Use a `Generic` when you want to share common attributes or relationships across multiple node types. This helps to avoid redundancy and ensures consistency across your schema. For example, if you have different types of network interfaces (physical, logical) that share common attributes like name and description, you can define a `Generic` interface with these attributes and have the specific interface types inherit from it.
42
+
43
+
`Generic`s can also be used to connect multiple types of Nodes to the same relationship.
44
+
45
+
When deciding between a `Node` and `Generic`, remember that computed attributes can only be used on `Nodes`, not `Generics`.
46
+
47
+
If a `Generic`'s properties are updated after the `Node` has been created, these updates will not be propagated to the `Node`; users must manually update `Nodes` if they want to reflect changes made to `Generic`s. See [Inherited properties](#inherited-properties) for more information.
48
+
49
+
### Node example
36
50
37
51
In the example below, the node `Person` has 2 attributes (`name` and `description`) and the node `Car` has 1 attribute (`model`) and 1 relationship to `Person`, identified by `owner`.
0 commit comments