database 什么是投影?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3461099/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 07:49:21  来源:igfitidea点击:

What is a Projection?

databasenhibernaterelational-algebra

提问by DaveDev

What is a Projection, in terms of database theory and NHibernate when using SetProjection()?

在使用 SetProjection() 时,就数据库理论和 NHibernate 而言,什么是投影?

回答by nvogel

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}.

例如,如果关系 R{A,B}, 包含三个元组 {1,10},{2,10},{3,20} 那么 R 在属性列表 {B} 上的投影将包含 2 个元组:{ 10},{20}。

In short, projection is more or less equivalent to SELECT DISTINCT in SQL (excluding cases with nulls and duplicate columns).

简而言之,投影或多或少相当于 SQL 中的 SELECT DISTINCT(不包括空值和重复列的情况)。

回答by Jon Skeet

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).

很简单,它是一个函数,它接受输入(例如数据库行)并产生输出(例如行中的一列,或者基于多列的一些计算)。

回答by Bilal Anees

Projection means subset of columns in a query.

投影意味着查询中列的子集。

select x, y, z from YourTable 

x, y, z is the projection here.

x, y, z 是这里的投影。

回答by dave Ozoalor

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 hereand here

如果您熟悉 SQL 或数据库表:投影是指要返回的字段/列/属性的数量。选择处理要返回的行数/记录数。这里这里有很好的视频解释

回答by dotjoe

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()).

就休眠而言,就像指定要选择的列一样。与让映射决定获取哪些列相反。这意味着您可以通过 ProjectionList 指定 sql 函数、子查询、单列或以上所有内容。例如,如果您想计算表中的行数SetProjection(Projections.RowCount())

回答by kn3l

also call projection

也叫投影

It is also call projection, please check the diagram

也叫投影,请看图

Projection reacts to eventsin the system

投影对系统中的事件做出反应

Project is simple listener.

项目是简单的listener