motofoto 0 Newbie Poster

Hi

I have a problem with inheritance (Generalization / Specialization). As far as I understand, you can implement inheritance in Relational Data-Base by (zero or one) to one relation, so how to make sure that Lecturer and Student are not the same Person, giving that Lecturer and Student are generalized by Person.

Student
PersonID ..PK,FK
Grade

Lecturer
PersonID ..PK,FK
Salary

Now mistakenly you can give Lecturer and Student the same PersonID.

if this is a common case, and there is no (design way) to prevent this in RDB. How do I prevent this case by triggers, how to use triggers to avoid insertion in one table if it is exist in another, I think it will be efficient only if PersonID is indexed.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.