Professional Web Applications Themes

question about relation on E-R diagram. - MySQL

Hallo, I'd like to post a question: I have two tables A and B. I have for A identifier called ida I have for B identifier called idb A-R-B If I have a relation (more to more) R on E-R diagram the copuple (ida,idb) should be or must be a kay for the table which represent the relation? Sorry for my little english, Thank you in advance for your help, Mario....

  1. #1

    Default question about relation on E-R diagram.

    Hallo,
    I'd like to post a question:

    I have two tables A and B.
    I have for A identifier called ida
    I have for B identifier called idb

    A-R-B

    If I have a relation (more to more) R on E-R diagram the copuple (ida,idb)
    should be or must be a kay for the table which represent the relation?

    Sorry for my little english,
    Thank you in advance for your help,
    Mario.

    _mario.lat Guest

  2. #2

    Default Re: question about relation on E-R diagram.

    _mario.lat wrote: 

    Mario,

    If I understand you correctly, you have two tables, 'A' and 'B', with a
    many-to-many relationship, with private keys 'ida' and 'idb', respectively.,

    You want to know if the relations table 'R' should (or must) have a key
    on 'ida,idb'.

    If I understand your question correctly, then yes, I generally create a
    primary key on 'ida,idb' for two reasons. The first it to ensure the
    combination is unique (I don't need the same relationship entered
    twice). The second is for speed - it makes searches on 'ida' or
    'ida,idb' faster. And depending on what I need, I may make another
    index on 'idb,ida' to speed up searches where idb is required first.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    net
    ==================
    Jerry Guest

  3. #3

    Default Re: question about relation on E-R diagram.

     
    Yes!

    Thank you for your answer.
    My problem was on DB teory and in particular on what Relationship (R)
    means. I was Wrong because I used R in other way: For example if I have
    Person and Product and I want to know relationship which products a
    person buys and in which date he buys the protuct. I did that:

    Create table person (idperson,name)
    Create table product (idproduct,name)
    Create table _?__ (idperson,idproduct,date)

    these tables are correct but the problem is when I'm tryng to draw
    this in E-R diagrams:

    PERSON----R----PRODUCT
    |
    date

    Is wrong because __?__ can contain more than one row with the same couple
    (idperson,idproduct) (because a persona can buys the same product in
    different dates)

    This (R) is not a relationship but an entities(SELL)! So the
    right way to rapresent it is:

    PERSON----R---SELL---R----PRODUCT
    |
    date

    SO the tables are the same but the E-R diagrams are
    different! My problem was on db theory, in particular on relationship
    meaning on E-R diagrams.

    Thank you in advance,
    Mario.




    _mario.lat Guest

Similar Threads

  1. One-to-Many Relation Question
    By staufman@gmail.com in forum MySQL
    Replies: 5
    Last Post: November 27th, 07:17 PM
  2. C function taking a relation and returning a similar relation.
    By Ben Martin in forum PostgreSQL / PGSQL
    Replies: 0
    Last Post: January 3rd, 03:23 PM
  3. diagram in Illustrator
    By helias in forum Adobe Illustrator Windows
    Replies: 3
    Last Post: August 7th, 07:56 AM
  4. Diagram Crash
    By Joe_Dempsey@adobeforums.com in forum Adobe Indesign Windows
    Replies: 3
    Last Post: April 30th, 12:04 PM
  5. ER Diagram
    By Riz in forum Microsoft Access
    Replies: 1
    Last Post: July 31st, 10:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139