Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2010
    Posts
    3

    Relationship between records

    Hi folks.

    I've got a relatively simple task I'd like to perform but not too sure on the 'correct' way pf creating the database schema.

    I'll describe my query in the form of an example.

    I have table A that contains a list of Servers

    Table B contains a list of Services that could be installed on a server

    A simple one to many relationship would be created between the two so that any one server could be hosting one or more services.

    Now the part I'm stuck on...

    I want to create a third entity that will list services that are dependant on each other. E.g. Active Directory is dependant on DNS. Therefore I'd like an entity that would reference two servers - I'm informed you can only have one foriegn key between two tables.

    E.g. I can't have field ServerA relating to Services as well as field ServerB also relating to services.

    Is this correct? Is there a better way of designing the database?

    Hope this makes sense and thanks in advance.
    Ryan

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by rapowell88 View Post
    I have table A that contains a list of Servers

    Table B contains a list of Services that could be installed on a server

    A simple one to many relationship would be created between the two so that any one server could be hosting one or more services.
    Before answering your question, are you sure about that? Can a server not host many services? And can a service not be hosted on many servers?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Jul 2010
    Posts
    3
    sorry, I'll try explain myself a little better. I should have said they'd be four entities. It's been a long day...

    -Servers-
    ServerID (PK)
    HostName
    IP

    -Services-
    ServiceName (PK)
    Port

    -Paring-
    ServerID (FK)
    Service (FK)

    So the paring table will match what server hosts what service(s). I now need a forth table that will list service dependencies. Something along the lines of:

    -Dependencies-
    ServerA (FK)
    ServerB (FK)

    Will an entity allow me to have to FK fields going to the same field in another entity? Is there a better way of acheiving this?

    Note: There'll probably be more fields per entity, this is just a basic example.


    Thanks

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    I think you've mentioned it yourself, that "services [...]are dependant on each other", not servers. From that point of view your -Dependencies- entity does not make much sense.

  5. #5
    Join Date
    Jul 2010
    Posts
    3
    You have a point n_i...

    But surely dependant services will still need a way of recording that, and one service can (and are) dependant on greater than one other service.

  6. #6
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Quote Originally Posted by rapowell88 View Post
    Will an entity allow me to have to FK fields going to the same field in another entity?
    Yes, why not?

Posting Permissions

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