Subquestion to my other question about what the UNIQUE
argument on INDEX
creation is for:
All definitions of (MS SQL Server) indexes (that I could find) are ambiguous and all explanations, based on it, narrate something using undefined or ambiguously defined terms.
What is the definition of index?
For example, the most common definition of index from Wikipedia is:
A database index is a data structure that improves the speed of data retrieval operations on a database table at the cost of slower writes and increased storage space. Indexes can be created using one or more columns of a database table...
†SQL server creates a clustered index on a primary key by default. The data is present in random order, but the logical ordering is specified by the index. The data rows may be randomly spread throughout the table. The non-clustered index tree contains the index keys in sorted order, with the leaf level of the index containing the pointer to the page and the row number in the data page.
It still feels ambiguous to me. One can understand an index as:
- An ordered data structure, a tree, containing intermediate and leaf nodes;
- Leaf node data containing values from indexed columns + "pointer to the page and the row number in the data page"
Can non-clustered index be non-unique, considering 2)? or, even, 1) ?
It doesn't seem so to me ...
But does TSQL imply the existence of a non-unique non-clustered index?
If yes, then What is understood by non-clustered index in the MS Create Index docs, and to what the argument UNIQUE is applied there?
Is it:
- Leaf node data containing values from indexed columns but without pointer + row number
If it is 3), then again question 1) arises - why apply constraints to copy of real data in an "index", instead of real data in-situ?
Is a bookmark (pointer+row number) to a real data row unique (does it uniquely identify rows)?
Doesn't this bookmark constitute part of the index and thereby make the index unique?
Can you give me the definition of the index instead of explaining how to use it UNDEFINED? The latter part I already know (or can read myself).
† This paragraph no longer exists in the current revision of the Wikipedia page, but did at time of posting.