Alberto
Alberto

Reputation: 607

OrientDB: Is it possible to define a vertex which is instance of multiple classes?

I'm experimenting with OrientDB and I would like to model a non disjunctive inheritance. For example: - there are Person - a Student is a Person - a Worker is a Person - "Alberto" is both a Student and Worker. Is it possible to model this situation with only the three classes I defined (Student, Worker, Person) or shall I introduce a new class WorkingStudent, extending both Worker and Student, containing "Alberto"?

I suppose a vertex cannot be instance of more than one class since the system would not know in which cluster to put it but I haven't found an explicit answer to my question, yet.

Cheers,

Alberto (the working student :-) )

Upvotes: 0

Views: 339

Answers (2)

silverfox1948
silverfox1948

Reputation: 917

I think you may trying to solve this the wrong way. For instance, Alberto will presumably always be a Person. But when Alberto graduates, he will no longer be a Student. In fact, he might also lose his job and no longer be a Worker. Moving him from one class to another is a considerable issue.

I'd create separate, smaller nodes of Worker and Student. Then create edges from Person to Worker, or Person to Student. The edge can be named "Is A".

Now, it is very easy to add new categories, for instance "Parent" or "Spouse", without having to worry about changing your class inheritance.

One of the fantastic advantages of a Graph database...

Upvotes: 1

Alessandro Rota
Alessandro Rota

Reputation: 3570

in OrientDb a vertex can be an instance of multiple class. Use this command

create class WorkingStudent extends Working,Student

Kind regards.

Upvotes: 1

Related Questions