Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Database Design
»
Design Ideas and Questions
»
design database
design database
Rate Topic
Display Mode
Topic Options
Author
Message
harri.reddy
harri.reddy
Posted Thursday, October 25, 2012 7:55 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, February 21, 2013 12:01 PM
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
Post #1376997
Grant Fritchey
Grant Fritchey
Posted Thursday, October 25, 2012 8:39 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 1:09 PM
Points: 13,383,
Visits: 25,187
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 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #1377042
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.