oracle - patient table database design -


i have 2 tables patient , doctor:

create table  "patient" (        "patient_id" number not null enable,     "patient_name" varchar2(40),     "age" number,     "sex" varchar2(12),     "place" varchar2(40),     "phone_number" number,     "doctor_id" number,     "registration_date" date,     constraint "patient_pk" primary key ("patient_id") enable,     constraint "doctor_id" foreign key ("doctor_id")     references  "doctor" ("doctor_id") enable 

)

create table  "doctor" (         "doctor_id" number not null enable,     "doctor_name" varchar2(40) not null enable,     "place" varchar2(40),     "phone_number" number,     constraint "doctor_pk" primary key ("doctor_id") enable ) 

a patient can visit doctor several times (different doctors also), have insert values on 1 key. here patient_id primary key can't accept multiple values on key.

how can recognize record uniquely tells doctor visits of patient? how create patient table suit requirements?

if doctor can visit patient more once create additional table like

create table doctor_visits ( doctor_id int references doctor(doctor_id) patient_id int references patient(patient_id) visit_date date constraint visit_pk primary key (doctor_id,patient_id,visit_date ) ) 

this allow 1 visit per day. if need more, i'd add time date field.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -