Sunday, March 11, 2012

Diagram one to one in 2005

How do you create a one to one relationship from the diagram in Sql Server
2005?
All the relationships I create between tables from the diagram tool, shows
the tables as one to many.
Thanks,
TomIf by one to one, you mean every row in Table A must have exactly one
corresponding row in Table B and every row in Table B must have exactly one
corresponding row in Table A, the way to do that is to make one table out of
those two tables. If there is some reason they cannot be one table, you
will have to enforce this by triggers and/or by maintaining these tables
with stored procedures.
If by one to one, you mean one to zero or one, that is, every row in Table A
has zero or one corresponding rows in Table B, but can't have more than one,
then create a normal foreign key relationship from Table B to Table A, and
then make the foreign key columns in Table B unique.
If you mean something else, please give us a description of what you want.
Tom
"tshad" <tshad@.dslextreme.com> wrote in message
news:OTuWc1HXIHA.5340@.TK2MSFTNGP06.phx.gbl...
> How do you create a one to one relationship from the diagram in Sql Server
> 2005?
> All the relationships I create between tables from the diagram tool, shows
> the tables as one to many.
> Thanks,
> Tom
>|||"Tom Cooper" <tomcooper@.comcast.no.spam.please.net> wrote in message
news:en3XUPIXIHA.4476@.TK2MSFTNGP06.phx.gbl...
> If by one to one, you mean every row in Table A must have exactly one
> corresponding row in Table B and every row in Table B must have exactly
> one corresponding row in Table A, the way to do that is to make one table
> out of those two tables. If there is some reason they cannot be one
> table, you will have to enforce this by triggers and/or by maintaining
> these tables with stored procedures.
Actually, that was how I had it - 1 table. But the customer wants to split
out the data that is specific to the entity. Another reason is that there
are many large fields that are mainly comments and that could potentially
make a row 10K.
> If by one to one, you mean one to zero or one, that is, every row in Table
> A has zero or one corresponding rows in Table B, but can't have more than
> one, then create a normal foreign key relationship from Table B to Table
> A, and then make the foreign key columns in Table B unique.
No I mean one to one. But I would have the same problem if I was using zero
to one.
How do I do that from the wizards?
The value in the foreign table is not a key just a value. It has another
primary key for the table.
In EM it shows the relationship between the tables using this field. Do I
explicitly need to make this a key in EM?
Thanks,
Tom
> If you mean something else, please give us a description of what you want.
> Tom
> "tshad" <tshad@.dslextreme.com> wrote in message
> news:OTuWc1HXIHA.5340@.TK2MSFTNGP06.phx.gbl...
>> How do you create a one to one relationship from the diagram in Sql
>> Server 2005?
>> All the relationships I create between tables from the diagram tool,
>> shows the tables as one to many.
>> Thanks,
>> Tom
>

No comments:

Post a Comment