SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 06/03/2013, 07:33 PM   #11
AndreT
Gangsta
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 992
Reputation: 410
Default Re: [MySQL] Table structure and foreign keys

Quote:
Originally Posted by Sinner View Post
You should tell something about the good practices when creating queries. Things people should avoid (like using IN, SET operators, explicit joins, LIMIT, etc...) + why you should avoid subqueries (they are always slower) and things people should definately use or atleast attempt to use (like JOINs and GROUP BY). If a query is properly built up it can be executed 100x faster.
What... source?

By the way, nicely written tutorial, thank you
AndreT is offline   Reply With Quote
Old 09/03/2013, 12:56 PM   #12
Luis-
High-roller
 
Luis-'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 4,059
Reputation: 339
Default Re: [MySQL] Table structure and foreign keys

Would this work for a house renting system? Say I made a 'house_renters' table with the 'hID' row working along side the 'ID' row of the 'houses' table.
__________________
Luis- is offline   Reply With Quote
Old 09/03/2013, 03:16 PM   #13
AndreT
Gangsta
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 992
Reputation: 410
Default Re: [MySQL] Table structure and foreign keys

If your amount of renters is n > 1, you'll most likely be better of doing that. If you'll maximally have one or two renters per house, you don't have to.

It would be a crime to have a string list delimited by commas for example. Look up 1st Formal Norm and database normalization to know more about the subject.
AndreT is offline   Reply With Quote
Old 20/03/2013, 08:27 AM   #14
KyleSmith
High-roller
 
KyleSmith's Avatar
 
Join Date: Mar 2009
Location: United Kingdom
Posts: 2,374
Reputation: 284
Default Re: [MySQL] Table structure and foreign keys

EDIT: Thanks, it is now working.

Nice tutorial! +rep.
KyleSmith is offline   Reply With Quote
Old 20/03/2013, 09:11 AM   #15
Michael@Belgium
High-roller
 
Michael@Belgium's Avatar
 
Join Date: Dec 2010
Location: Belgium
Posts: 3,047
Reputation: 986
Default Re: [MySQL] Table structure and foreign keys

Perfect tutorial Vince !
__________________
Mah Github. - Mah Youtube
Interested in a full featured and cheap derby gamemode or need host-tab ? Contact me on skype: michael.belgium
Michael@Belgium is offline   Reply With Quote
Old 12/04/2013, 02:51 AM   #16
Kar
High-roller
 
Kar's Avatar
 
Join Date: May 2010
Location: Black Asylum
Posts: 3,333
Reputation: 426
Default Re: [MySQL] Table structure and foreign keys

So how do i make it if I change the username in the parent table, it gets updated in all tables?
__________________
Kar is offline   Reply With Quote
Old 12/04/2013, 05:36 AM   #17
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,845
Reputation: 2567
Default Re: [MySQL] Table structure and foreign keys

You shouldn't have a username in any other table but the base table. All other tables should link to it via an id. I guess you can make a foreign key that references the name field, but it surely isn't the most effective way.
__________________
Vince is offline   Reply With Quote
Old 12/04/2013, 06:22 AM   #18
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,448
Reputation: 961
Default Re: [MySQL] Table structure and foreign keys

Nice tutorial. I have looked in to foreign keys before and gave up, but they seem so simple I may have to look in to it again.
MP2 is offline   Reply With Quote
Old 14/04/2013, 12:45 PM   #19
Jay_
Beta Tester
 
Jay_'s Avatar
 
Join Date: Jul 2009
Posts: 669
Reputation: 179
Default Re: [MySQL] Table structure and foreign keys

Excellent tutorial. It's about time somebody expressed the importance of database normalisation around here!
Jay_ is offline   Reply With Quote
Old 24/07/2013, 03:55 PM   #20
dusk
High-roller
 
dusk's Avatar
 
Join Date: Jul 2008
Posts: 1,118
Reputation: 46
Default Re: [MySQL] Table structure and foreign keys

Firstly, i know that i'm bumping a pretty old thread, but since it's a tutorial i think it's okay.

I just wanted to ask, is there like part 2 of this? It's really a great tutorial and i want to learn more about table structures and other cool MySQL stuff (like these relations).

The manual is pretty boring....This thread was way clearer for me.
dusk is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Table JaKe Elite Scripting Help 5 13/11/2012 07:53 AM
MySQL: Update all values in table from another table kurta999 Scripting Help 8 23/08/2012 08:55 PM
MYSQL Table thefatshizms Scripting Help 3 31/07/2012 02:06 AM
mysql table bug juraska Scripting Help 4 15/12/2011 07:34 AM


All times are GMT. The time now is 11:05 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.