Você está na página 1de 3

Explain the concept of foreign key.

Foreign key is nothing but simply we can say, "a field in one table related to field in
another table". See the below example:Consider, there are two tables like emp_personal and emp_official.
In emp_personal table , the fields are empid, empname, dob for example. In this table,
empid is the primary key field.
In emp_official table, the fields are empid, dept, designation for example. In this also,
empid is the Primary key or may not be a Primary key field.
Now we relate these two tables using the foreign key relationship. Foreign key
relationship is used to avoid the redundancy mainly.
Now, emp_personal is the Check table (Because it holds the empid field, which has
the primary key...)
emp_official table is the Foreign key table (Because it holds the empid field, which
may or may not be a Primary key).
Now, the foreign key relationship is given. (click the KEY Like icon in ABAP Dict Database Table : Emp Official )
Tables are ready to enter the records...for example create some 5 records in the
emp_personal table .
Table : emp_personal : Primary Key - empid
empid
--------1
2
3
4
5

empname
-------------AAA
BBB
CCC
DDD
EEE

empdob
-----------1.1.1990
2.2.1990
3.3.1990
4.4.1990
5.5.1990

Status
--------------------Record saved successfully
Record saved successfully
Record saved successfully
Record saved successfully
Record saved successfully

Records are saved in the table : emp_personal.


Now, we are trying to create records in emp_official table.
Table : emp_official : Primary Key or not a Primary Key - empid

empid
--------1
2

dept
-------------Dept1
Dept2

designation
-----------S.E
S.SE

Status
--------------------Record saved successfully
Record saved successfully

Now, if you try to create the record which is not in the table emp_personal, which has
the empid = 6. But it'll not allow us to create the record 6, because of the foreign key
relationship between these two tables....
6

Dept6

P.M

Record doesn't exist......

Now, the foreign key relationship helps us to avoid the duplicate entry.
Foreign key relationship is possible between the tables having at least one same type
of field. Also, the Technical characteristics of the fields should be same. This is done
in the value table.
This is the concept of Foreign key.

What is the difference between INCLUDE,CUSTOMIZING


INCLUDE and APPEND structure in a table/structure?
6/28/2014
0 Comments
APPEND structure and Customizing Include are meant for enhancing the Standard
Tables/Structures in customer perspective.
Normal Include structure is used to add fields to Z Tables.
APPEND structure : An append structure is a structure that is assigned to exactly one table or
structure. There can be more than one append structure for a table or structure.
Append structure is used to add additional fields to standard SAP tables.
Append structure cannot be used with cluster and pooled tables.
Append structure is included in a table/structure using .APPEND
The name of a append structure can begin with Z* / Y* .

INCLUDE structure:
Both Customizing Include and normal Include are included in a table/structure
using .INCLUDE
Customizing Include : Some SAP Standard tables/structures are delivered with
Customizing/Customer Include which act as container of custom fields.So Customers can
thus enhance tables and structures of the standard system without themselves having to modify
the table and structure definitions.
In contrast to append structures,a Customizing include can be contained in several tables or
structures.
The name of a customizing include begins with 'CI_' and the include is in the customer
namespace.
The fields in customizing includes need to be in customer namespace (YY* / ZZ*) in order to
avoid conflicts with future fields added by SAP to the same table/structure.
Normal Include structure can be used in multiple tables/structures and structure name can begin
with Z* / Y*.

Você também pode gostar