SQL query and possible relation

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default SQL query and possible relation

    i have a problem about the DB relation. for information, i'm using MS Access.
    The problem is, how can i refer the foreign key to another primary key? let me
    show it clearly. I have 2 tables in one DB. I name it as a tbl_modul and
    tbl_dftr_mod.

    The contents in these tables:

    tbl_modul
    id | code | subject |
    -----------------------------------------------
    1 A1001 Math
    2 A1002 Science
    3 A3300 Biology

    tbl_dftr_mod
    id_std | code1 | code2 | code3 -->> code15
    -------------------------------------------------------------
    F102 A1001 A1002
    F103 A3300
    Ryunosuke Guest

  2. Similar Questions and Discussions

    1. recursive relation in datagrid
      I have a table with this structure itemID naam image parentID I want to make a datagrid that contains a hyperlinkcolumn. When i click on the...
    2. Can't find relation oid
      Hi, I have the following problem: I use libpq inside SRF functions (like in dblink) and I create some tables to store results coming from...
    3. C function taking a relation and returning a similar relation.
      Hi, Please CC me as I'm not on the list. I'm trying to write a closed frequent itemset data mining custom function for postgresql. The optimal...
    4. [PHP-DEV] some public relation for php 5
      *This message was transferred with a trial version of CommuniGate(tm) Pro* Hi all, after the RC/Beta-discussion of php5 i habe set up a separate...
    5. Positioning MIAWs in relation to the Stage
      I am working with MIAWs as pop up panels. Is it possible to position the MIAWs. i.e. define the rect points in relation to the stage position rather...
  3. #2

    Default Re: SQL query and possible relation

    I think a better structure would be to use three tables: "module", "student"
    and "studentModule". The the third table "studentModule" would contain the
    modules (zero or more) for each student. Note - that the foreign keys in this
    table are the numeric student and module record Id's not their string "codes"


    MODULE
    moduleId | code | subject |
    -----------------------------------------------
    1 A1001 Math
    2 A1002 Science
    3 A3300 Biology


    STUDENT
    studentId | code
    -------------------------------------------------------------
    1 F102
    2 F103

    STUDENTMODULE
    id | studentId | moduleId
    -------------------------------------------------------------
    1 | 1 | 1 <!--- Student F102, A1001 Math
    1 | 1 | 2 <!--- Student F102, A1002 Science
    1 | 2 | 3 <!--- Student F103, A3300 Biology

    With this structure you can easily query the three tables to retrieve the
    information you need and can use the GROUP attribute of CFOUTPUT to format the
    output as desired.




    mxstu Guest

Posting Permissions

  • You may not post new threads
  • You may 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