What is a Projection, in terms of database theory and NHibernate when using SetProjection()?
Projection is one of the basic operations of Relational Algebra. It takes a relation and a (possibly empty) list of attributes of that relation as input. It outputs a relation containing only the specified list of attributes with duplicate tuples removed. In other words the output must also be a relation.
Example, if the relation R{A,B}, contains three tuples {1,10},{2,10},{3,20} then the projection of R over the attribute list {B} would contain 2 tuples: {10},{20}.
In short, projection is more or less equivalent to SELECT DISTINCT in SQL (excluding cases with nulls and duplicate columns).
Very simply, it's a function which takes an input (e.g. a database row) and produces an output (e.g. one of the columns from the row, or perhaps some calculation based on multiple columns).
count(columnName)
–
Foxhole Projection means subset of columns in a query.
select x, y, z from YourTable
x, y, z is the projection here.
In terms of hibernate, it's like specifying what columns to select. As opposed to letting the mappings determine what columns are fetched. This means you can specify sql functions, subqueries, a single column, or maybe all of the above via a ProjectionList. For example, if you wanted to count the rows in a table SetProjection(Projections.RowCount())
.
If you are familiar with SQL or database tables: Projection refers to the number of fields/columns/attributes to return. Selection deals with number of rows/records to return. There are good video explanations here and here
© 2022 - 2024 — McMap. All rights reserved.