Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean that 'OOP languages are organized around graphs'?

Tags:

oop

sql

In Learning SQL the Hard Way, the author says:

OOP languages are organized around graphs, but SQL wants to only return tables

What does it mean for an OOP language to be organized around a graph? Does this refer to data being stored in specific memory addresses?

like image 506
Aaron Fraser Avatar asked Oct 03 '14 01:10

Aaron Fraser


Video Answer


1 Answers

As Nick.McDermaid comments above, the relevant sense of graph is the abstract data type.

In an object-oriented language, the "object graph" consists of objects and the "has-a" relationships between them. For example, a Person object might have a field of type Collection<Address>, in which case the object graph would include the relationship from the person to all of his/her addresses.

The sentence immediately following your quotation is, "If SQL returned a nested data structure then this wouldn't be a problem." If you select from a PERSON table, you will not automatically get all of the corresponding rows from ADDRESS. You can do a JOIN, of course, but then the result-set will include one copy of the PERSON row for each of its corresponding ADDRESS rows. So you have to do some translation work, after getting your query results, to create the object graph that you would like to work with.

like image 162
ruakh Avatar answered Sep 28 '22 06:09

ruakh