1.how do i manage this in database? 2.Q on auto_increment
Posted: Mon Jan 16, 2006 1:40 am
(php/mysql)
i just started to learn database by myself.
For practice, recently i am trying to make a web contacts program like facebook but definately not that complex.
So far a user can enter and save personal info into the database in the program. The next question coming to me is, how to manage the buddy lists in the database.
Say user Applecat has 70 buddies and user Catdog has 50 buddies. Do I save all 120 buddies(70+50) in a same table in the database, which is like:
If it is managed as above, the thing I am concerning is, if I have 500 users, the table grows to about 30,000 lines; it is a table to be acessed by searching very frequently. Would it be a very low efficiency?
Or there are other much better ways to manage these data?
In facebook, they even showed every connection between you and a stranger, like
You :: Nick :: Ryan :: Thomas
You :: Nick :: Jared :: Thomas
You :: Nick :: James :: Thomas
How can they do that? I am thinking if I am still managing my data as the way I talked about previously, there will be a lot of calculation going on by loading one page!
Problem on auto_increment
When I am making this program, adding one user will create profiles on 2 different tables. In these tables, there will be an Identical # for each user in order to keep the related data from different tables. The # is created by auto increment. Now I am adding on more table to keep some other details for the user. There will be 3 tables keeping user data totally.
Somehow by adding and deleting data, The new added table has a different ID# created by auto_increment.
The increment # in the orininal tables are fine, but in the new added table:
no good. How do I adjust the auto_increment back to the corresponding number?
Thanks!
i just started to learn database by myself.
For practice, recently i am trying to make a web contacts program like facebook but definately not that complex.
So far a user can enter and save personal info into the database in the program. The next question coming to me is, how to manage the buddy lists in the database.
Say user Applecat has 70 buddies and user Catdog has 50 buddies. Do I save all 120 buddies(70+50) in a same table in the database, which is like:
Code: Select all
C1 | C2 | id
=================================
Applecat | adamB | 1
Applecat | SuanK | 2
......... | .....
Applecat | BOOM | 70
Catdog | Brian | 71
Catdog | adamB | 72
......... ..........
Catdog | GoldKid | 120Or there are other much better ways to manage these data?
In facebook, they even showed every connection between you and a stranger, like
You :: Nick :: Ryan :: Thomas
You :: Nick :: Jared :: Thomas
You :: Nick :: James :: Thomas
How can they do that? I am thinking if I am still managing my data as the way I talked about previously, there will be a lot of calculation going on by loading one page!
Problem on auto_increment
When I am making this program, adding one user will create profiles on 2 different tables. In these tables, there will be an Identical # for each user in order to keep the related data from different tables. The # is created by auto increment. Now I am adding on more table to keep some other details for the user. There will be 3 tables keeping user data totally.
Somehow by adding and deleting data, The new added table has a different ID# created by auto_increment.
Code: Select all
Table1
==================
lg_ID lg_username
1 silverme
2 lim
3 thousand
4 big big
5 love
==> 8 loves
Table2
==================
kk_ID kk_name
1 silverme
2 lim
3 thousand
4 big big
5 love
==> 8 lovesCode: Select all
Table3
==================
mm_ID mm_username
1 silverme
2 lim
3 thousand
4 big big
5 love
==> 6 lovesno good. How do I adjust the auto_increment back to the corresponding number?
Thanks!