Php Masters!
I need to know how you do things the way you do things.
Let us say, I am building a Social Network (SN).
Let us say, my mysql db looks like this in structure:
METHOD 1
Tbl: users;
Columns: id, username, email, friends.
Example:
id|username|email|friends
0|uniqueideaman|uniqueideaman@**.com|user1,user500 ,user697
Do you see, how I have crunched-up 3 usernames into a single cell ?
Q1. Is this how you would do it to list my friends' usernames ?
---------------
METHOD 2:
I was told I should do it like this:
Anyway, I was told to check these out:
https://en.wikipedia.org/wiki/Fourth_normal_form
Did not bother with the vid as I'm on low bandwidth.
Also, googled:
https://www.google.com/search?q=what...hrome&ie=UTF-8
You php pro, do you think I should have a friends list where every member link is recorded in a three column table, the first being an auto_increment ID to keep all records sequential and unique, the 2nd ID is the User ID (UID) and the Friend ID is the FID ?
Tbl: Friends
ID is auto incremented.
UID is User's ID.
FID is Friend's ID.
Columns
ID | UID | FID
1 | 3 | 24
2 | 3 | 399
3 | 55 | 24
4 | 598 | 3
5 | 598 | 55
6 | 6000 | 598
7 | 3 | 598
8 | 24 | 55
9 | 55 | 598
So, you think apart from having the "users" tbl that lists the users during registration, I should have another tbl "friends" ?
And you want me to populate the "freinds" tbl like shown above. Right ? Yes or no ?
If "yes", then how would you db query to pull-up a user's friends ? Let's say you want to pull-up UID 5's friends.
This is my try using PREP STMNT:
In the above example you can see that ID's 1 & 2 have two entries for UID 3 who is linked to friend's FID 24 & 399 and is also friends with UID 598.
It appears that I am having multiple links here. And therefore, I did not originally want to do it this way to save the db getting populated to much (too many entries) to save it from getting bogged down from doing too many tasks.
Q2. Would not it be less resource using and less querying (hence less traffic to the db) if I do it the way I demonstrated in my original post ?
I need to know how you do things the way you do things.
Let us say, I am building a Social Network (SN).
Let us say, my mysql db looks like this in structure:
METHOD 1
Tbl: users;
Columns: id, username, email, friends.
Example:
id|username|email|friends
0|uniqueideaman|uniqueideaman@**.com|user1,user500 ,user697
Do you see, how I have crunched-up 3 usernames into a single cell ?
Q1. Is this how you would do it to list my friends' usernames ?
---------------
METHOD 2:
I was told I should do it like this:
Anyway, I was told to check these out:
https://en.wikipedia.org/wiki/Fourth_normal_form
Did not bother with the vid as I'm on low bandwidth.
Also, googled:
https://www.google.com/search?q=what...hrome&ie=UTF-8
You php pro, do you think I should have a friends list where every member link is recorded in a three column table, the first being an auto_increment ID to keep all records sequential and unique, the 2nd ID is the User ID (UID) and the Friend ID is the FID ?
Tbl: Friends
ID is auto incremented.
UID is User's ID.
FID is Friend's ID.
Columns
ID | UID | FID
1 | 3 | 24
2 | 3 | 399
3 | 55 | 24
4 | 598 | 3
5 | 598 | 55
6 | 6000 | 598
7 | 3 | 598
8 | 24 | 55
9 | 55 | 598
So, you think apart from having the "users" tbl that lists the users during registration, I should have another tbl "friends" ?
And you want me to populate the "freinds" tbl like shown above. Right ? Yes or no ?
If "yes", then how would you db query to pull-up a user's friends ? Let's say you want to pull-up UID 5's friends.
This is my try using PREP STMNT:
PHP:
$stmt = mysqli_prepare($conn, "SELECT FID FROM users WHERE UID = ? ");
It appears that I am having multiple links here. And therefore, I did not originally want to do it this way to save the db getting populated to much (too many entries) to save it from getting bogged down from doing too many tasks.
Q2. Would not it be less resource using and less querying (hence less traffic to the db) if I do it the way I demonstrated in my original post ?