Neil,

you wrote :
>I have just recently started using SAP DB, and am impressed with the range of
>features available, however I have encountered a problem when establishing 
>referential integrity between primary keys.  
>Basically, I just don't seem to be able to do it.  
(...)
>Further info:  The problem occurs when trying to establish RI between 
>TBL_STUDENTS (PK:Student_ID, Forename, Surname etc), 
>TBL_ENROLMENTS (PK/FK: Student_ID, PK/FK: Course_Code, DateOfEnrolment) and 
>TBL_COURSES (PK: Course_Code, Title, Level etc)

from the information you provided, i assume you want
to create an FK reference to a column which belongs to
a composite PK. 
probably you get an error message because this column
was not defined to be unique (said equivalently : to have
a unique index on it) by itself, only the composite PK
is required to be unique.

we know that it is not possible in SQL Studio to 
define a column to be unique if it already belongs 
to a PK (i.e. not in one step); 
i posted the following not long ago :

>> Nono, I mean the fancy graphical table editor. If you mark 
>> column as PK,
>> you cannot mark it as unique anymore.
 
> it should be possible to create a composite PK
> and define some (except at least one) columns in 
> it to be unique; but in SQLSt it is not. Thanks for 
> reporting the bug.
> (however, you will get an error from the db kernel
>  if you try to define all of the columns in a PK
>  as unique. to prevent this in the non-composite case,
>  the 'unique' box in the dialog is  disabled if the 'key'
>  box was checked.
>  Due to unlucky encapsulation attitude in the vb sources 
>  of SQLSt it would be  a _lot_ of work to check if a 
>  given column definition in this dialog belongs to a 
>  composite PK or to a single column PK; it is unlikely 
>  that this will be corrected unless we rewrite the whole 
>  table def dialog.)

if you want to work graphically, there is a workaround :
- create the table with the composite PK on it.
- create the unique indexes on your FK target columns 
  afterwards (right mouse click on the table icon at left,
  new->index (don't forget to mark the 'unique' checkbox in
  the dialog)).

  
regards,

Markus Stausberg
SAP Labs Berlin
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to