In CSS, the more HTML elements you specify, the more precedence the selector gets. This is known as "specificity." For example,
div p span {...}
Is more specific than, and thus would override:
span {...}
In SQL, one can start a query like:
SELECT database.table.columnOne, database.table.columnTwo FROM ...
The same query can be expressed, less specifically, as:
SELECT columnOne, columnTwo FROM ...
Is there a proper term in SQL for being more specific in queries, or is it just called "specificity" like in CSS?
Best Answer
That's not true. CSS specificity is very complex because it's trying to apply conflicting rules rather simply disambiguate. While I understand what you're talking about SQL suffers no such problem with identifiers as queries are either executed with certainty or an error is thrown.
The intent here is different, "specifity" doesn't exist.
In the context given we would say
<catalog>.<schema>.<table>.<column>
is "fully qualified", as in it leaves no further room for ambiguity. This definition comes from ISO9075-1.,NOTE 3
is referring to routines being typed,catalog.schema.myRoutine(text,text)
can be different fromcatalog.schema.myRoutine(int,int)
.This is massively different from "specificity" which implies cascading mutability -- if we say "show all animals" and "hide all dogs" and "show collies" what should happen?
In CSS, you have to know if multiple rules can apply to the same identifier, which one has precedence in the event they conflict. In SQL, the rule-set is much simpler. If there is any ambiguity, things will throw a fatal error. All databases that I can think of forgo any attempt at guesswork. Preventing that fatal error from being thrown requires qualification of your "identifiers".
For instance, the following creates a result set that returns two
x
(some databases would likely throw an error here),but the second you say you want
x
withSELECT x
rather thanSELECT *
all databases that I know of throw an error,Logically you may ask what the equivalent of SQL "fully qualified" identifiers in CSS. That would be a simple identifier (
id
attribute selectors). The spec requires identifiers be absolute, thus there is no ambiguity when you specifyIt's infinitely (fully-) (globally-) "specific" (qualified), and far more specific than
Actually there is a small rabbit hole I'm excluding and that's XHTML namespaces and Foreign Elements. which do in fact provide for multiple
#Lassie
s (that is to say identifiers aren't always globally unique)