Jump to content

[SOLVED] Whether to normalise


jaymc

Recommended Posts

I have 2 tables, one is `MEMBERS` which contains member info such as age, name, gender

 

Then I have another table called `FRIENDS` which contains members friends, however, it also contains  a gender field

 

The reason for this is to avoid a double query or a join to pull out the gender from a query that pulls out friends

 

For example, if I had a script that displayed all members friends and there gender, it would be one query to my friends table to get everything I need

 

However, if there was no gender field in the friends, I would need to add a join to pull it out from my members table

 

Normalisation and joins are supposed to be an optimized way of handling database, Im just wondering if my approach would work better

 

Feedback would be great

Link to comment
Share on other sites

That was just an example, I have 20 tables with similar setups like that

 

In some scripts I will need table info and in addition there email address for instance, which is also available from the members table

 

So, rather than using a join or 2 queries I just put the email in with the table.

 

The alternitive is to just have it left in members, and use a join in the query to pull it out. I suspect that will work against me though in regards to optimizing mysql queries

Link to comment
Share on other sites

rather than adding the column , I would suggest go for JOIN.

 

because EMAIL is unique for each member it doesn't make any sense having that coulmn in 2 tables as long that is not a PRIMAY KEY for one table and FOREIGN KEY for another table.Although its just an example it depends on the data you put in the coulmns determines wheather you can add column and go for a join.

Link to comment
Share on other sites

But using a join is essential 2 query tables where as even if I had email repliacted accross a few tables, I can get away with using 1 query to get what I need

 

Why do you advise to use join when focusing on optimization?

 

My reason for join is mainly to reduce the size of the database, the less replication the small the tables which I suppose is optimization ni its self. Its just a case of how well it fairs up

 

Larger databases = less queries

Smaller databases = more queries

 

Who wins

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.