3

Suppose I have a table named Service. But I have other tables that have a similarities with that table like RoomService, ConsultatonService, etc.

Can the Id of RoomService and ConsultationService keep a foreign key reference to Service table's ServiceId column but being identifiable by the Type column in the Service table?

Many association in a single fieldstrong text

4

Yes, you can do it. Your services table will store all the common attributes between your sub-classes.

If you intend to avoid 1:1 relationships, you'll have to create, for example, an ServiceId column and do the relationship with it, using Id as PK of RoomService. By the way, there is no problems with 1:1 relationships, specially in your case, where you are creating specialized sub-classes.

In addition, the type column will be used by your application to determine which subclass the object is. Also no problem on that.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.