Finding the exact term for an SQL expression

I am trying to document some SQL and would like to get the correct terminology. If you write SQL like this:

select child.ID, parent.ID from hierarchy child inner join hierarchy parent on child.parentId = parent.ID 

Then you have one actual table (“hierarchy”) that you give two names (“parent” and “child”). My question is about how you are referencing the logical entity of a table named.

What would you write in an empty place for a name?

"This query uses one table (hierarchy), but two _ (child and parent)"

[edit] left the previous project in question. now fixed.

+4
source share
4 answers

In SQL Server table_source term table_source :

Specifies the source of a table, view, or view with or without an alias for use in a Transact-SQL statement

In BNF grammar, this is:

 <table_source> ::= { table_or_view_name [ [ AS ] table_alias ] [ <tablesample_clause> ] [ WITH ( < table_hint > [ [ , ]...n ] ) ] | rowset_function [ [ AS ] table_alias ] [ ( bulk_column_alias [ ,...n ] ) ] | user_defined_function [ [ AS ] table_alias ] [ (column_alias [ ,...n ] ) ] | OPENXML <openxml_clause> | derived_table [ AS ] table_alias [ ( column_alias [ ,...n ] ) ] | <joined_table> | <pivoted_table> | <unpivoted_table> | @variable [ [ AS ] table_alias ] | @variable.function_call ( expression [ ,...n ] ) [ [ AS ] table_alias ] [ (column_alias [ ,...n ] ) ] 
+2
source

I believe this is called MOST JOINING. A and B (or "child" and "parent", I think you have a typo in your question) are called ALIASES or TABLE ALIASes.

+5
source

self join concept. However, a is a syntax error. hierarchy table, alias child .

I would call each part of the self-join instance .

+4
source
 'child', 'parent' 

The term used in the SQL-92 Standard specification is a “correlation name”, which is a type of “identifier”.

 'hierarchy' 

The term used in the SQL-92 Standard specification is a “table”.

Therefore, the answer to your (edited) question is:

This query uses one table (hierarchy) but two correlation names (child and parent).

+1
source

All Articles