SELECT CASE WHEN employee.type = 'contract' THEN salary CASE WHEN employee.type = 'full-time' THEN salary + benefit_costs END CASE FROM employee
Tell me how is this declarative?
-SQL is functional -CSV is not a language, it's a data format -GraphQL, im not familiar -JSON is literally executable javascript code, arguable -React is a javascript framework, binding is a declarative nature (if it has it, i dont know it too well), but it is not a language, it's a framework -HTML is absolutely, 100% declarative, yes
A "case" statement in SQL (or an "iif") is still declarative, how else would you express specific cases when necessary?
iif and case by itself is not declarative or imperative. only an entire language can be described as such
when you create html, you dont care how the rectangle is drawn, you focus on defining the result itself.
if sql was declarative, than the code of the SQL above would be: GIVE ME ALL THE COST OF THE EMPLOYEES --, I DONT CARE ABOUT THE DETAILS
the details, which in this example the difference between fulltime/contract employees would be handled by the framework (SQL server) which would already has a concept of two kind of employee like in HTML can have rounded tips of rectangle or angular tips, because the framework already understand these ideas
an SQL query itself (if no structured language used) is just a big function applied on a set. It has never have a concept of the things you do, like building an accounting solution to a company. HTML has the concept of paragraphs, button, etc etc, all the things you wanna do. but with SQL you step by step define what you want by conditions and transformations.
or another way to separate them -imperative is a combination of -sequence/condition/loop
-function -no loop (cardinality is always multiple) -sequences is encoded as data -conditions <- yes it has conditions
This is exactly what SQL is. There are exceptions, but they're exceptions.
> an SQL query itself (if no structured language used) is just a big function applied on a set.
I don't think you have a correct model of SQL. SQL is a language that expresses definitions, not functions. It is absolutely declarative.
Some extensions of SQL can provide functional capabilities, yes, but they are exceptional.