VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 1[2] ]
Subject: Re: one-to-one í sql


Author:
Hjálmtýr
[ Next Thread | Previous Thread | Next Message | Previous Message ]
Date Posted: 22:21:22 17/Sep/2007
In reply to: user 's message, "one-to-one í sql" on 18:40:22 17/Sep/2007

>Ef hægt er að skilgreina many-to-one og one-to-many
>með primary key (key) og many-to-many með primary
>key(key1,key2,key3...) hvað skilgreinir þá one-to-one
>vensl ?

Ég er ekki alveg viss um að ég skilji þessa spurningu, en við sjáum ekki eins mikið af 1-to-1 venslum eins og hinum
gerðunum. Það eru þó til dæmi þar sem venslin eru raunverulega 1-to-1. Eitt dæmi væri vörugeymsla þar sem
vörur eru geymdar í vöruhólfum. Hvert vöruhólf getur aðeins innihaldið eina vörutegund, og hver vörutegund er
bara í einu vöruhólfi (ef hún er til).
Í þessu tilfelli væru tvær töflur með sitthvorum aðallyklinum (primary key), líklega vörunúmer í vörutöflunni
og hólfnúmer í hólfatöflunni. Síðan yrði önnur hvor taflan með hinn aðallykilinn sem ytri lykil hjá sér. Til dæmis
hólfataflan með vörunúmer sem ytri lykil sem vísaði í vörutöfluna.
Til dæmis:

create table vorur (
vorunr integer primary key,
lysing char(50))

create table voruholf (
holfnr integer primary key,
vorunr integer,
stadsetning char(30),
foreign key (vorunr) references vorur)

[ Next Thread | Previous Thread | Next Message | Previous Message ]


[ Contact Forum Admin ]


Forum timezone: GMT+0
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.