Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Is this ER diagram right?

Author  Topic 

tempo
Starting Member

4 Posts

Posted - 2014-06-27 : 05:03:13
When I connect two table should they always have a column in common with each other?

For example the 'patients' and 'doctors' tables in that ER are connected to say each doctor can have many patients and each patient can have many doctors, but they have no columns in common. Is it right?

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-06-27 : 05:19:25
you can have a bridge table which brings both patientid and doctorid

Javeed Ahmed
Go to Top of Page

tempo
Starting Member

4 Posts

Posted - 2014-06-27 : 05:23:15
wat?
Is it right or wrong?
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-06-27 : 05:26:54
yes,you need to have a common column to connect both the tables.

Javeed Ahmed
Go to Top of Page

tempo
Starting Member

4 Posts

Posted - 2014-06-27 : 05:29:33
And if the given in the question is "each doctor can have many patients and each patient can have many doctors" then I have to create that extra table to show this yes?
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-06-27 : 07:30:58
yes,as i mentioned in the earlier post

Javeed Ahmed
Go to Top of Page

tempo
Starting Member

4 Posts

Posted - 2014-06-27 : 09:13:29
And to satisfy that condition, what should the bridge table be called, and what numbers should be on the relation line?
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2014-06-27 : 17:18:00
Call it what you like (Floyd?). The important thing is that an try indicates a relationship exists between this doctor and this patient. From your diagram, it looks like SSN_D and SSN_P would be the unique identifiers for doctor and patient. A bridge table (btw, this type of table goes by many other names) could simply be those columns but you could also add columns to hold other attributes of this Doctor-Patient entity. For instance, when was the last time this doctor saw this patient, when was the first appointment, is this the primary care physician for the patient, etc?



Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy
Go to Top of Page

naveedraza
Starting Member

1 Post

Posted - 2014-06-30 : 01:13:41
@ahmeds08

Assalamualaikum ahmed bhai, can i have your mail id ?

Mohammad Naveed
Go to Top of Page
   

- Advertisement -