sql 1 to 1 relationship table setup -
if have parent item report, called study , each study has 1 supreporta, subreportb , subreportc. , each subreport belongs 1 report, 1 1 relationship, should set tables study table having
study ------- id subreportaid subreportbid subreportcid
or should set tables each subreport has study id
subreporta ----------- id reportid subreportb ---------- id reportid subreportc ---------- id reportcid
which way best practice , why? help in advance....
since have role 1 study has 1 type of each sub study , vice-versa right model be:
table report
report id pk
table subreport
subreport id pk idreport (fk->report) idtypesubreport (fk->typesubreport) (add unique id,idreport)
and table typesubreport
typesubreport id description
this way not have duplicated info anywhere.
hope helps.
sql
No comments:
Post a Comment