Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


design database


design database

Author
Message
harri.reddy
harri.reddy
SSC-Enthusiastic
SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)

Group: General Forum Members
Points: 149 Visits: 346
i am desiging database and i need answer.

for example i am getting flat file ,which contains pharmacy into and patient info

pharmacy :

pharmacyid primary key
name

patient:

patientid primary key
firstname
lastname

now they dont have any relation between them,
i can have multiple record of patients from same pharmacy, that i need to store, so if there is pharmacyid is primary key, how can i store tha record.

similarly i can have multiple records for same patient from different pharmacy.

what should i do

please help me with design, what kind of relation i need to make,do i need to create third table
Grant Fritchey
Grant Fritchey
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17617 Visits: 32267
The basic design is quite simple. You have to create an interim table that has the primary key from patient and the primary key from pharmacy. That creates the many to many join that you need.

Unfortunately, depending on how the data is coming from your pharmacy, loading this could be tricky. Are the primary keys for the patient unique across pharmacies? Or is it only unique within a pharmacy? If it's only unique within a pharmacy, then you have to have some other method of identifying patients. If all you have is first and last name, you're in trouble. There can be more than 'Li Wong' so just relying on the name is going to hurt you. With that other unique constraint you can just look up the primary key from the person as you perform the loads and put them into the interim table.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search