Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Creating Foreign key in DB View

Former Member
0 Likes
2,749

Hi all,

Please tell me if it is possible to create foreign keys in Database View. If possible,

then how can I create?

Thanks and regards,

Ridhima

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,724

Thanks for your response.

Actually I have currency and quantity fields in my View and I need to create a BW data source with this view. I searched BW forum also and found some solution to refer to currency and quantity fields in base tables of the view. I tried doing this but still not able to solve the problem.

If you have any inputs, plz let me know.

Hi all,

Please tell me if it is possible to create foreign keys in Database View. If possible,

then how can I create?

Thanks and regards,

Ridhima

7 REPLIES 7
Read only

Former Member
0 Likes
1,724

hi,

we can create foreign keys only in the database table and not in the views.

And more over database view is used to dipaly particular fields from LOGICALLY REALTED TABLES,

here LOGICALLY RELATED TABLE mean the tables which are related with foreign key only.

you cannot cretae foreign key realtiosnhip in the views.

Reward points if useful.

Regards

Naveen

Read only

ashok_kumar24116
Contributor
0 Likes
1,724

Hi Ridhima Gupta,

Good check out the following documentation

To create DB view go to tcode SQ02 specify the view name .

Now u can create view by using the join or other options.

Remeber when u join there should be table with fields in common.

A foreign key links two tables T1 and T2 by assigning fields of table T1 to the primary key fields of table T2.

Table T1 is called the foreign key table (dependent table) and table T2 the check table (referenced table). The pair of fields for the two tables must have the same data type and length. One field of the foreign key table therefore corresponds to each key field of the check table. This field is called the foreign key field.

A foreign key permits you to assign data records in the foreign key table and check table. One record of the foreign key table uniquely identifies one record of the check table using the entries in the foreign key fields.

Have a look at below link for details.

http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ea77446011d189700000e8322d00/frameset.htm

I hope it helps.

Good luck and thanks

AK

Read only

Former Member
0 Likes
1,724

hi,

we can create foreign keys only in the database table n not in view.....view is a virtual table where we can get the data either from a single table or multiple table as a single entity......n coming up to database view here can get the fields from more than one table without having any relationship.....

i suppose u must have got a clear idea m=now...if soo dont forget to reward with points.

with regards,

madhuri.

Read only

Former Member
0 Likes
1,724

HI

you cant create foreign keys to Views.

Instead can create to DB taables..

Views does not contain data in it. It fetches data from the database only depending on the condition ...Views are join on some one/more tables.

rewards if useful

regards,

nazeer

Read only

Former Member
0 Likes
1,724

Hi Ridhima,

yes, U can create foreign keys in data base view.

Go to se11.create view. as u provide join coditions .then u can provide foreign key for field of the view.

Reward points if helpful.

Regards,

Hemant

Read only

Former Member
0 Likes
1,725

Thanks for your response.

Actually I have currency and quantity fields in my View and I need to create a BW data source with this view. I searched BW forum also and found some solution to refer to currency and quantity fields in base tables of the view. I tried doing this but still not able to solve the problem.

If you have any inputs, plz let me know.

Read only

Former Member
0 Likes
1,724

Hi Hemant,

Thanks for ur reponse.

I gave joining conditions in the view but when I select the field and click on Foreign Key, it displays a message 'No foreign key defined for this field'.

Ridhima