If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Relationship between records

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-23-10, 12:21
rapowell88 rapowell88 is offline
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old 07-23-10, 12:35
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
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:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #3 (permalink)  
Old 07-23-10, 14:38
rapowell88 rapowell88 is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 07-24-10, 09:28
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
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.
Reply With Quote
  #5 (permalink)  
Old 07-26-10, 04:56
rapowell88 rapowell88 is offline
Registered User
 
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.
Reply With Quote
  #6 (permalink)  
Old 07-27-10, 09:28
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
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?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On