Re: E/R questions

From: <Dan>
Date: 1997/05/16
Message-ID: <5lhl6j$n1h_at_drn.zippo.com>#1/1


In article <337B2D9B.6D04_at_lpp.sdi.agate.net>, Jay says...
>
>I have an entity that contains zip code and city.
>
>I would like to establish another entity called distance that contains
>"From zip", "To zip" and "distance". Any ideas on how to represent this
>in an Designer/2000 E/R diagram?
>
>Should distance be a sub-type within zip, and have a recursive (pig's
>ear) relationship to itself? i.e.
> ZIP
> -------------------------
> | zip code |
> | city |
> | |
> | -------------- |
> | |distance | |
> | ------------- |
> |-----------------------|
>
>The sub-type has a recursive relationship to itself. Is this valid?
>
>Or is there a better way to represent this?
>
>Thanks.

What you really have here is a cross reference table where you are cross referencing from the same table. I would have two separate entities Like this:

        ZIP                                     DISTANCE
    ---------------------                     --------------------
    | city              |  ZIPCODE_FROM       | distance         |
    | zip_code          | -----------------|< |                  |
    |                   |  ZIPCODE_TO         |                  |
    |                   | -----------------|< |                  |
    |                   |                     |                  |
    ---------------------                     --------------------

Where you have the relationships part of the UID for the DISTANCE table. Both relations are optional on the ZIP end, but mandatory on the DISTANCE end. You could probably get away with it being mandatory on the ZIP end, but I try to avoid such things in cross-ref tables just because the management of the cross-ref table can get to be cumbersome on complex tables.

I hope I answered your question. Just remember, this is how _I_ would have done it. The beauty of these new tools is that there are many ways to accomplish the same thing. It all depends on your way of thinking and doing.

Dan Received on Fri May 16 1997 - 00:00:00 CEST

Original text of this message