Frage

I am currently working on a piece of work where I have an issue trying to relate two tables, one of which is a sub class due to generalisation.

Table A has a primary key of staffID and I would like to relate this to a foreign key in a generalised table (Table B). The super class (table C) of table B has the staffID field and therefore the generalisation should carry this from table C in to Table B.

However when using the diagram view to set up a FK relationship, when I look in the drop down fields, I can only see the attributes in Table B and none of the super classes (Table C) attributes and hence not staffID.

To give more context to the situation, there are two types of staff, one can create data in all tables of the generalisation and so is linked directly to the super class by staffID, however the other type of staff can only add data to one of the sub classes.

               Super Class C
                 (staffID)

Sub Class D                     Sub Class B(FK) ----------- table A (PK)
                                                              (staffID)

Thanks in advance

War es hilfreich?

Lösung

I'm not sure I understand your question. But in order to set a foreign key reference from B to C, the column C.staffID must be either a primary key, or it must have a UNIQUE constraint.

This SO answer might give you some useful guidance.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top