‎2007 May 02 3:24 PM
PLS CARRIFY NY DOUBT
what is foreign key .what is the purpose of it. pls tell abou this indetail.
database table fields are client indenpedent or dependent?
‎2007 May 02 3:28 PM
Hi,
You can define the relationships between tables in the ABAP Dictionary by creating foreign keys
http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ea77446011d189700000e8322d00/content.htm
tables are Clinet Independent and the Data is the Client Dependent, we can see the data of a client in another client
Regards
Sudheer
‎2007 May 02 3:32 PM
A foreign key is a field (or fields) that points to the primary key of another table. The purpose of the foreign key is to ensure referential integrity of the data. In other words, only values that are supposed to appear in the database are permitted.
For example, say we have two tables, a CUSTOMER table that includes all customer data, and an ORDERS table that includes all customer orders. The constraint here is that all orders must be associated with a customer that is already in the CUSTOMER table. In this case, we will place a foreign key on the ORDERS table and have it relate to the primary key of the CUSTOMER table. This way, we can ensure that all orders in the ORDERS table are related to a customer in the CUSTOMER table. In other words, the ORDERS table cannot contain information on a customer that is not in the CUSTOMER table.
The table fields are client independent whereas the data in a table is client dependent if the table has a client field in it and client indenpedent if it does not have the client field in it.
Regards,
Ravi.
‎2007 May 02 3:32 PM
Foreign Key mean that field is a primary key in another table.
Consider the sales order table
Sales Order customer currency material
000000001 ABCD INR XYZ
000000002 ABCD JPY XYZ
000000003 ABCD EUR XYZ
next, consider a table with amounts of sales order
sales order amount
000000001 1000
000000002 2000
000000003 3000
In the second table, all the sales order must exist in the first table. So it is a foreign key in second table.
Database fields are cannot be client dependent. Entire tables can be client dependent or independent. If any table has a field MANDT of TYPE CLNT, then it is client dependent, else it is client independent.
‎2007 May 02 3:32 PM
Hello Kumar
Tables (but not table fields) are either client dependent or independent. If the CLIENT field is part of the primary key then this table is client-dependent (e.g. table KNB1 has field MANDT as primary key field).
If you display table KNB1 in transaction SE11 you will see that field BUKRS has a foreign-key relation to table T001. This foreign-key relation takes cares that you cannot enter company codes that are not defined in the system (table T001).
Regards
Uwe
‎2007 May 02 3:35 PM
Hi
Have a look on:
http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ea77446011d189700000e8322d00/content.htm
In general Tables are client Independent only unless you make them client depedent at the time of creation.
Regards,
sreeram
‎2007 May 02 3:43 PM
Hi kumar,
1. what is foreign key .what is the purpose of
It comes into picture while designing database tables.
Eg. In purchase order table, we can enter material number.
This material number SHOULD always come from Material Master,
so that wrong code is never entered.
<b>Hence, in the table for PO, we specify that field of material number
as Foreign KEY and link it to the field of master table for material master.</b>
2. database table fields are client indenpedent or dependent
Client indepenent and dependent comes into picture
<b>not for FIELDS</b> ,
but for Data in which the table resides.
(or we can say table is client dependent or independent)
(<b>If the Table contains the first field as MANDT,
then it is client dependent, other wise not --- thats the only criteria)</b>
regards,
amit m.