数据库连接程序
数据库连接程序:当外部表中的属性通过转换进行处理时,将它们连接到传入的特征。
The DatabaseJoiner queries an external table to retrieve attributes associated with a feature. One or more feature attributes are joined to one or more columns in a table in the database, and the values from the matching table row(s) are added as feature attributes.
The_matched_recordsattribute specifies how many records in the database the feature matched to.
输出端口
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
成功匹配的功能。
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
Features that had no matches.
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
如果Cardinality是set to必须匹配Exactly One或必须匹配0或1, then features that do not meet the criteria are rejected.
Parameters
DatabaseJoiner是一个非常强大的转换器,具有许多与性能相关的设置。
读卡器
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
Select the Reader format and dataset where the table resides, including any format-specific parameters.
加入
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
Specify the table to join. Click the Browse button to select the table from a list. Note that you can only select this after you have completely specified the reader format, dataset, and format-specific parameters.
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
Select the attribute(s) from the incoming feature and their corresponding table field(s) that will be used to find matches. Matches are made when the values of all the attributes equal the values of their corresponding table fields.
There is one row for each attribute and column pair in the table entry widget. You can add more pairs by clicking the plus (+) button located to the right of the table. Similarly, you can remove pairs by pressing the minus (-) button. A minimum of one pair must be specified for the join to work.
从“要素属性”列的下拉列表中选择属性。(您可以直接在相应的表字段中键入,也可以通过单击“浏览”按钮从列表中选择。)要使用“浏览”按钮列出可用的表字段,需要指定从表中读取所需的所有信息。
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
指定匹配表行中要连接到传入要素的字段列表。
To select the fields from a list, click the Browse button. A dialog showing the list of possible fields will appear. Place a check next to each field you wish to add, and click OK.
如果未指定任何字段,则将添加匹配行中的所有字段。
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
Indicate the type of relationship between the database rows and each feature. This will describe how many rows will match to each feature and what action the DatabaseJoiner will take if the expected number is not found.
关系类型 | Description |
---|---|
Match All (1:M) | A feature can match to any number of records, all of which will be joined based on the value of the多个匹配项parameter. |
Match First (1:0..1+) | A feature can match to any number of records, or none at all, but only the first record found will be joined. |
必须正好匹配一个(1:1) | Each feature MUST match to one record only. Zero matches or more than one match will cause feature rejection. |
必须匹配0或1(1:0..1) | Each feature MUST match to a single record or none at all. More than one match will cause feature rejection. |
注:The必须匹配规则很严格。如有疑问,请使用Match First或Match All.
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
Specify how results of multiple matches will be given.
Create a feature for each match:将匹配的每一行添加到传入功能的副本中。在这个场景中,对于中的每个特性,都会有匹配的特性。如果没有匹配项,该功能将退出Unjoinedoutput port.
Add fields on a list attribute: Each row matched is added to a list attribute on the feature. If there are no matches, the feature exits theUnjoinedoutput port.
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
The name of the list attribute to append multiple matches.
注:List attributesare not accessible from the output schema in Workbench unless they are first processed using a transformer that operates on them, such as李斯特普洛德或列表串联器. All list attribute transformers are displayed in the Contents pane of the Transformer Help underLists. Alternatively,属性曝光器can be used.
Merge Attributes
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
如果Merge Joined是chosen, attributes from the feature and table will be merged, and in case of conflicts the value specified in theConflict Resolutionparameter will be used. IfPrefix Joined则所有传入属性都将在Prefixparameter.
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
This parameter is enabled when积累模式是set toMerge Joined.Use Original和Use Joinedwill give priority to original and incoming attributes respectively in case of attribute conflicts.
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
The specified value is used as a prefix for incoming attributes when积累模式是Prefix Joined.
优化
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
不rmally the cache is filled with records as they are matched in the database. However, for formats that support SQL, the cache can be preloaded (that is, filled with a specific set of data before matching takes place) by issuing a prefetch query. This prefetch query can select an entire table or a selected part of a table which is most likely to be matched by the feature attributes.
注:Unless the prefetch query is exhaustive, cache size limits apply. See Prefetch Exhaustive to learn what constitutes an exhaustive prefetch query
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
A prefetch query which is known to retrieve all possible matches is called anexhaustive query. When a match cannot be found within the cached results of an exhaustive query, it is assumed that no match exists in the database; thus the database will not be further consulted.
如果Prefetch Exhaustive是set toYes,这表示预取是否详尽无遗。即使设置为不, however, any prefetch query is assumed to be exhaustive when it does not contain a WHERE clause, and is of the form:
SELECT * from TableName
注:When FME considers a prefetch query to be exhaustive, the cache size limit will be ignored. This is because the cache must contain all results from the query.
For example, a number of FME features of type "roads" require a database match. The database table (myrecords)有一个领域(record_type) with a number of values; roads, highways, avenues, streets. The FME features will only ever be matched to whererecord_type=roads因此,如果发出以下预取,则整个连接过程将更加高效:
从myrecords中选择*,其中record\u type='roads'
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
Specify the number of rows to cache locally if you do not want to accept the default of 5000. You can optionally specify an SQL query to preload the cache. Note that cache size is ignored if the prefech query is exhaustive.
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Skins/Default/Stylesheets/Images/transparent.gif)
Engaging trimming of key fields may significantly reduce performance and should only be done if key column values in the database are known to contain trailing spaces.
It has no effect if an exhaustive prefetch query is used (see above for an explanation ofPrefetch Exhaustive).
注:This parameter is included for backwards compatibility and most users will have no need to use it. The parameter can only be accessed using the pane of the Workbench.
Tip:
Usage Notes
关系FeatureMerger
featuremerge连接工作区中正在读取的两个数据集。featuremerge还可以使用其Merge Type参数。featuremerge在内存中执行所有连接,因此如果在同一数据上有多个关系,那么它可以比DatabaseJoiner更快。DatabaseJoiner联接由数据库使用SQL执行。文章FME2011 Use Case: Joiner vs FeatureMerger包含这些变压器的更详细的比较。
关系内联查询器/SQLCreator/SQLExecutor
The DatabaseJoiner is very useful and efficient when there exists a one-to-one or one-to-many relationship between data flowing through FME and data held within a database. If it can be used, the DatabaseJoiner can be more efficient than using either the InlineQuerier or SQLCreator/SQLExecutor, provided that the DatabaseJoiner key fields have indexes in the source database. DatabaseJoiner allows simple join relationships based on multiple attribute keys and requires no knowledge of SQL – this is often very effective for simple lookup tables. SQLCreator/SQLExecutor allow more complex joins and these are executed by the source database.
The InlineQuerier is useful in cases where data sources have no SQL ability, or for more complex queries. The InlineQuerier allows you to ask more sophisticated questions about the data than the DatabaseJoiner.
Example
Editing Transformer Parameters
使用一组菜单选项,可以通过引用工作空间中的其他元素来指定转换器参数。更高级的功能,如高级编辑器和算术编辑器,也可以在一些变压器。要访问这些选项的菜单,请单击在适用参数旁边。有关详细信息,请参阅Transformer Parameter Menu Options.
Transformer Categories
Search FME Knowledge Center
Search for samples and information about this transformer on theFME Knowledge Center.