Is the SQL language object-oriented?

20

Is the SQL language object-oriented? If so, could you show an example?

    
asked by anonymous 24.07.2017 / 13:12

3 answers

23

SQL stands for Structured Query Language , that is, it is a structured language, specific for manipulation in relational databases (eg SQL Server, MySQL etc. ).

Therefore, object orientation is not supported on it.

There is also NoSQL , which some call Not Only Structured Query Language and others Structured Query Language , which uses other templates such as Documents and Graphs.

  

NoSQL databases use a variety of data models, including documents, graphs, key-values, and columnar data.

Source: Amazon NoSQL .

I still do not consider it as a language that provides object orientation, because for that, it would need to support inheritance, encapsulation, and polymorphism, which are Object Oriented concepts.

    
24.07.2017 / 13:23
18

It's not even a programming language . So it would not be worth analyzing whether it has mechanisms of object-oriented programming languages. It does not support paradigms typical of programming languages. It does not have all the capabilities of a Turing Machine .

Although the name includes the structured word, it also has nothing to do with the structured programming paradigm.

It does not have any object-oriented pillars that are inheritance, encapsulation, and polymorphism. It does not have objects property, so it can not be oriented to them . Guidance requires much more than a basic programming language offers and SQL nor the basic offers.

SQL, as the name implies, is a query language, it is purely declarative and non-imperative

So you can only declare intentions. Of course in addition to queries we can do updates and model how we want the database, but we can not do structured operations, we can not command everything as we want by doing complete algorithms, let alone we can structure objects as defined in OOP.

Some SQL-based languages such as SQL Server T-SQL or Oracle PL / SQL and others are considered programming languages, even though they do not have object-oriented mechanisms. Unlike C that has some mechanisms that allow making OO code almost illegible, these languages have nothing to help it becomes virtually impossible to adopt the paradigm. Maybe some crazy way, but it would have huge mischief.

Someone may question whether it is possible to adopt an object-oriented model in SQL. The answer would be no, but it is possible to adopt an object-oriented model in the database tables, which is different from SQL. Even though the database does not offer many features it is still possible in some way, not totally, perhaps not even in all databases. Some DBs provide facilities for modeling tables as objects, but not SQL.

In addition, NoSQL is an access model, it is not even a language, so it does not fit comparisons.

Object orientation is overestimated. Today it is fashionable for everyone to want to do OO without even knowing if they will benefit from it. In fact it's common for people to say they're doing it and they're not, just to be fashionable. A "methodology" should be adopted for some benefit, and only after mastering it, which in the case of OO is not easy.

Complement: OOP is the same in all languages?

    
24.07.2017 / 14:09
2

Just complementing that PL / SQL already has implementation of Object Orientation, and very well, thank you. Before, with the packages, you can simulate, to a certain extent, a "Class", now you can actually create a Class, with its methods, properties, and everything that is entitled, and with it, an object of it, to manipulate within other Classes and / or other Packages and / or Procedures and / or Functions. That's the big cheap PL / SQL today, because we can have business layer objects, whose methods can execute code in methods of Class objects defined in PL / SQL itself. So the code in PL / SQL was much cleaner and easier to understand later.

    
18.09.2018 / 20:32