什么是投影?
从数据库理论和 NHibernate 的角度来看,使用 SetProjection() 时什么是投影?
What is a Projection, in terms of database theory and NHibernate when using SetProjection()?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
投影是关系代数的基本运算之一。它采用一个关系和该关系的属性列表(可能为空)作为输入。它输出一个仅包含指定属性列表的关系,删除了重复的元组。换句话说,输出也必须是一个关系。
例如,如果关系 R{A,B} 包含三个元组 {1,10},{2,10},{3,20},则 R 在属性列表 {B} 上的投影将包含 2 个元组:{ 10},{20}。
简而言之,投影或多或少相当于 SQL 中的 SELECT DISTINCT(不包括空值和重复列的情况)。
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).
投影是指查询中列的子集。
x,y,z 是这里的投影。
Projection means subset of columns in a query.
x, y, z is the projection here.
就休眠而言,这就像指定要选择哪些列。与让映射决定提取哪些列相反。这意味着您可以通过 ProjectionList 指定 sql 函数、子查询、单列或以上所有内容。例如,如果您想要计算表中的行数
SetProjection(Projections.RowCount())
。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())
.如果您熟悉 SQL 或数据库表:
投影是指要返回的字段/列/属性的数量。
选择涉及要返回的行/记录数。
这里有很好的视频解释
和此处
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