Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Database Foundations Joining Relational Data Between Tables in SQL Keys and Auto-Incrementing Values

still cant understand what the point from linking tables?

well here is images http://postimg.org/image/8amnthavl/ and here please http://postimg.org/image/8k19y7sp9/

as i saw in this lesson , the point from linking was avoiding repeated values ... but we've created know more 1 table and 2 more rows ?! also the problem is still , but instead of repeating items values, we repeating items id numbers?!

so i really cant get the point from linking ?! we've just made the code more difficulty, and longer and more memories used, and harder select statement with link (inner outer etc..) and we still have repeating values in the item_id?!!

i hope you guys can help me in this problem .

thank you .

1 Answer

From my understanding it is to take off the load from the server when sorting the data. If you have over a thousands rows of type VARCHAR and tell it to search, sort, or organize those a certain way it is working with larger amounts of data. When you setup the linked tables you now can have the database sort through smaller amounts of data like an INTEGER instead of a VARCHAR which would take some load off the server.

Example:

Lets say we have a link setup where 0 is "Action 1 is "Musical" 2 is "Thriller"

If you wanted to sort it alphabetically it would be easier to tell the database to DESC type INTEREGER than to DESC type VARCHAR. Given you would have to first sort the actual linked data a certain way, if you had a large amount of repeated data where multiple Strings could be represented as ids instead one sorting through the information will be faster. Also even editing the data would be a lot easier, as now you could edit 1 location and have it effect all instead of editing every single piece of data.

I think there is quite a few more reasons why you would want to do this, but if you are working with small amounts of data it would not matter to much. Though in the business world it is a good idea to improve the utilization of all your programs and databases.

Hope this helps!

Also he mentions at the end of the video that this will allow you to delete and update rows constraining on those keys without turn SQL_SAFE_UPDATES off.