This term is used for achieving database efficiency. For a good explanation of what/why click here. This tutorial will show you some common types of this. I will use one example and keep improving it starting from the beginning. The first thing I will do is give you a table structure, then we will improve it using the 2 most common techniques: “1 to 1”, and “1 to many”.
Current table structure: id, username, email, password, street_addy, city, state, zip, phone, browser, group_1, group_2, group_3, is_admin, verified
1 to 1 Relationship
The first thing you notice is that this table has a lot of columns, because we will not use them every time we search for a user, for instance validating login does not require ‘city’ or displaying a post may not necessarily require ‘phone’, etc. So we would use our 1 to 1 relationship to help simplify this process. The new table should contain it’s own unique id and the id of the user it corresponds with “uid” in this case.
Current table structure:
Users: id, username, email, password, verified, is_admin
Extra: id, uid, street_addy, city, state, zip, phone, browser, group_1, group_2, group_3When needing all of these this can still appear as the first one using a query like this:
SELECT * FROM `Users` LEFT JOIN `Extra` On Users.id=Extra.uid

1 to Many Relationship
The next problem we might notice is that we have a fixed number of groups, which might be what we want, but let's say this application we wanted as many as the user wanted, we don't wanna append a new column everytime the user wants a new one, right? How do we fix this? We might make a new table called "groups" that would have the same unique id, the user's id that points to the user and the group id, so 3 fields.
Users: id, username, email, password, verified, is_admin
Extra: id, uid, street_addy, city, state, zip, phone, browser
Groups: id, uid, group_idIf you don't know much about the user this might be a bit more of a complicated query, depending on what you already know. If you know the user id# then try this:
SELECT * FROM `Groups` WHERE `uid`=2If you don't know the user id# if you just know the username or something you could try something like this:
SELECT * FROM `Groups` WHERE `uid`=(SELECT `id` FROM `Users` WHERE `username`='BlaineSch')

There are lots of other relationships but that is all for this tutorial!