Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Problem To Join Tables In Database, Problem in joining (many to many) relation
.hack//GU
post Jul 28 2006, 12:24 PM
Post #1


Premium Member
********

Group: Members
Posts: 190
Joined: 21-October 05
Member No.: 13,185



Please help me. I'm building a group of database fro a program.
the situation is like this:

'user' may have 1 or more class(es).
'class' itself may have 1 or more user in its classroom.

I'm bad at explaining... maybe like this:

A program is made to write data of classroom. Hikaru has a math class at Monday and statistic class at Tuesday. The math class itself consists of about 50 students in a classroom.

So, Hikaru (user ) may have one or more class at time,
math class (class) may have one or more students at time.

So, basically I must make these two tables joined together. It is (many-to-many) relation in which I haven't known how to build. So, please tell me how I build these two tables.

Thanks in advance.
Go to the top of the page
 
+Quote Post
eirikureiriksson
post Jul 28 2006, 02:00 PM
Post #2


Newbie
*

Group: Members
Posts: 2
Joined: 28-July 06
Member No.: 27,425



Hi, your best option is to add the third table to handle the many to many relationships.
You have basically two options, first is allowing multiple identical links. In that case you should have three fields in the table, numerical primary key, student id and class id. Otherwise the relationship table should consist of at least two fields, Class ID and Student ID, which combined form the unique key for each entry.

CODE

               |ASSIGNEMENT|
|STUDENT|      |-----------|      
|-------|      |ASGN_ID    |      |CLASS   |
|ST_ID  |------|ST_ID      |      |--------|
               |CLASS_ID   |------|CLASS_ID|



This post has been edited by eirikureiriksson: Jul 28 2006, 02:19 PM
Go to the top of the page
 
+Quote Post
.hack//GU
post Jul 28 2006, 02:32 PM
Post #3


Premium Member
********

Group: Members
Posts: 190
Joined: 21-October 05
Member No.: 13,185



so, the third one. Hm... I'll try to take your advice. Thank you. Tomorrow I'll ask again if I'm still in trouble.
Go to the top of the page
 
+Quote Post
.hack//GU
post Aug 3 2006, 12:55 AM
Post #4


Premium Member
********

Group: Members
Posts: 190
Joined: 21-October 05
Member No.: 13,185



the project is now complete, thanks for the advice.

However, my supervisor said sometimes we may not use this kind of relation (many to many). He said we must break down the relation so that there will be no more many to many relation. Does this third table acceptable to make the whole relation to one to many?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Firefox 3 Cookies Problem(2)
  2. Import From Excel File Into Mysql Database(9)
  3. Mysql Database Not Working(3)
  4. Ips Installer Database Details [resolved](6)
  5. Problem Installing Sims 2 Nightlife(26)
  6. Mysql Database Setup : Setting Up Mysql Database(6)
  7. I Have A Girl Problem Here(27)
  8. Connect To Remote Oracle Database With Toad(7)
  9. Problem With My Girlfriend Family, Need Suggestions For Action(2)
  10. Problem With Page Redirect(8)
  11. Need Advice On Setting Up Mysql Database.(3)
  12. Nintendo International Clan(1)
  13. Remote Assistance Problem(8)
  14. Terminating Hosting Problem(1)
  15. Join The Best Runescape Clan On Earth(63)
  1. Browser Compatibility Problem With Firefox - Javascript + Css(3)
  2. How Many More Times Will I Have To Post About This?(11)
  3. Phpmyadmin(7)
  4. Domain Problem : This Is Important..(0)
  5. Skype / Xampp Port Conflict(5)
  6. Php Header Problem(11)
  7. A Problem With Ftp Clients(9)
  8. Youtube People That Do Not Respect Other Opinions(7)
  9. Laptop Keyboard Problem(7)
  10. Itunes Problem!(1)
  11. Problem Aligning In Firefox(9)
  12. Join The Vital Godz Runescape Clan!(1)
  13. Aznpridescape 24-7 :d(2)
  14. Problem Getting Text To Align With Different Resolutions(4)
  15. Dvd Drive Problem(10)


 



- Lo-Fi Version Time is now: 6th September 2008 - 05:14 PM