官术网_书友最值得收藏!

Table links—the key for the right query

Table links are fundamental for query building. You will see some different links in this section, but the most common links will be discussed in the next section because there are too many and they are used too often.

To understand table links, you need to know more about table structures.

Primary key

Every table has a primary key. Some of the tables have foreign keys too. All those keys are used for the index. Docentry is a typical primary key to link OXXX with XXXn document tables. For example, Docentry is a common key field to link OPOR with POR1, POR2 to POR12.

A primary key can be one or more fields. For a simple table one key field would be good enough. For a complicated table, two or more fields for primary key are not rare.

A primary key has to be unique within the same table. This key will not allow NULL value—that is, an empty field or a field with no data.

Foreign key

A foreign key is usually used to link to some other table's primary key. This field will be updated whenever the other table record has changed.

Although, you could link any fields between tables, if the field is not NULL, you should try to use key link wherever possible in order to increase the database performance.

Example of table links within SAP Business One

To be clearer about the link, here are a few table link examples:

  • OITM-Items table and ITM1-Items Prices table:

    These two tables are linked through ItemCode field. Both tables have the same field name to link. It is not one-to-one but one-to-many relationships. One Item Code in item master may have more than one item price associated.

  • OITT-Product Tree table and ITT1-Product Tree Child Items:

    These two tables are linked through Code field in OITT and Father field in ITT1. These tables are used for Bill of Materials.

  • OCRD-Business Partner table and OSLP-Sales Employee table:

    These two tables are linked through the same name field SlpCode. In the second table, SlpCode is the primary key for OSLP. On the other hand, it is a foreign key in the first table OCRD.

主站蜘蛛池模板: 远安县| 汉源县| 克什克腾旗| 冀州市| 唐海县| 肥乡县| 专栏| 甘孜县| 蒙自县| 阿拉善右旗| 永康市| 武清区| 榆林市| 肥城市| 洪泽县| 图片| 商城县| 固镇县| 栾川县| 客服| 陆川县| 房产| 临邑县| 社会| 措勤县| 绍兴市| 清镇市| 平湖市| 云浮市| 静海县| 兴隆县| 长宁区| 乌苏市| 年辖:市辖区| 岳阳县| 蒲江县| 泊头市| 静乐县| 东丰县| 昌乐县| 都匀市|