Very basic database theory.

Posted by John R on Stack Overflow See other posts from Stack Overflow or by John R
Published on 2011-03-06T23:55:27Z Indexed on 2011/03/07 0:10 UTC
Read the original article Hit count: 125

Filed under:

I have a set of tables to show the relationship between organziations and supporters below. Although I have done some basic mySQL querries, I know very little about database 'design'.

I plan to querry the database for:
-a list of contributors to a specific organization... or,
-a list of organizations that a specific suporter supports.
The database tables for organiations and contributors may have other columns in the future and recieve a lesser amount of querries based on that information.

A | X  
A | Y  
A | Z  
B | X  
B | Y  
C | X  
C | Z

How should the tables be set up? I assume that there should be a third table, but there is still redundent information in the third table. Is there a better way of setting up the tables?

+----+-------+    +-------------+----------+   +----+-------+  
| id | org   |    | org         | contr    |   | id | contr.|  
+----+-------+    +-------------+----------+   +----+-------+  
|  1 |   A   |    |           1 |        1 |   |  1 | X     |  
|  2 |   B   |    |           1 |        2 |   |  2 | Y     |  
|  3 |   C   |    |           1 |        3 |   |  3 | Z     |  
+----+-------+    |           2 |        1 |   +----+-------+  
                  |           2 |        2 | 
                  |           3 |        1 |  
                  |           3 |        3 |  
                  +-------------+----------+  

© Stack Overflow or respective owner

Related posts about database-design