Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2006
    Posts
    43

    Representing interfaces

    If you have an interface, such as Notifiable, and you want to represent that in your database, how would you do it? Assume you have 10 entities that should be Notifiable, but each are in their separate inheritance hierarchies.

    How would you let each one of those 10 entities represent their association to a Notifiable entity that has its own characteristics and relationships?

    Seems like a very interesting problem to me, but I can't think of any good (normalized, strong foreign keys) solution.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    what is an interface?

    there is only one way to represent things in a database, and that's with a table

    does having an interface table (whatever that is) with its own PK solve what you're trying to do? each of the 10 entities (other tables) would then have a FK to the interface table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2006
    Posts
    43
    An interface (Java) can be thought of as a superclass for the purposes of this discussion:

    A Car inherits from Vehicle only, but can also implement the interfaces Drivable, Turnable, Parkable, each of which can have its own properties.

    I'm essentially talking about multiple inheritance.

    Yes, what you suggest solves most of the problem, but (I should've combined it with my other question on discriminators) wouldn't each interface (i.e. superentity) table need discriminators for each of the 10 entities?

    And that'd create problems when adding a new entity that implements the interface.

    And there's the fact that multiple inheritance in data modeling is apparently an 'illegal' construct...

    So confused...

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    sorry, i don't do superclass inheritable multi-property java interface discriminators
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •