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

General Discussion

Kevin Korte
Kevin Korte
28,149 Points

Quick advice from more advanced developers?

Hello, I'll try to keep this brief.

Basically, I want to build a website that is a quick reference guide for power sport machines. I actually, have this functioning in wordpress, however I have concerns that it will quickly grow into a untaimable beast.

As an example, each machine will have it's own page, full of quick data in table format.

The problem comes that say 10 machines share the exact same OEM air filter part number. Awesome. So far I can build an "Air Filter" table, and reuse that for all 10 machines. However, for one of the aftermarket brands, only 5 of those 10 machines use one filter type, and the other 5 machines use a different filter of those, even though all 10 share the same OEM filter.

Kind of a weird problem, but I have to deal with it. Now instead of having one nice table I can use, I have two tables that I have to keep straight, but mostly still contain the same information.

I want to stay DRY.

So I'm looking at either PHP and possibly laravel, or Ruby and/or Ruby on Rail to build a custom CMS.

Ideally, I create a new data entry, where I fill out that this new parts is an air filter, with this manufacture, this part number, and a short description, and than assign that piece of data to all the machines it fits, rinse and repeat.

So when someone visits their machine's page, all of that assigned data gets queried into a table format. And on the back end, this information is only filled out once.

Does this sound logical. Any issues with relating the data inside a database and storing it? Any advice here?

I know I have my work cut out for me.

Hey Kevin,

Sounds like you're looking to build a pretty a web application with a pretty typical database design -- something that would be very easy to accomplish using a framework like Laravel, as you mentioned.

Your database would likely have three tables (if I'm understanding correctly):

1) MACHINES -- to store the machines and their basic info 2) PARTS -- to store different machine parts, such as the various air filters 3) MACHINES_PARTS -- to store relationships between the various MACHINES and their associated PARTS

As you can see by that design, that allows you to create single entries for each part in the PARTS table and establish many connections between MACHINES and PARTS by adding entries to to the MACHINES_PARTS table. (This is known as a many-to-many relationship; each machine can have many different parts, and each part can belong to (i.e. be associated with) many different machines). That all make sense?

If you're interested, I've actually created an entire course that walks you through building a complete Laravel application. So if you need any additional advice in that regard, I'd be happy to point you in the right direction.

Kevin Korte
Kevin Korte
28,149 Points

Hi Alexander,

I'm almost certain I'm going to go with Laravel at this point. Wordpress has been great to me, and I know I could still build this custom content creations with a custom plugin and possibly a additional table or two, but I have to wonder at what point am I taking WP too far.

I got Laravel installed and ready to go over the weekend, started playing around inside of it. Watched some screencast on many to many relationships, and how Laravel handles them, and it ended up making total sense. I'll take a look at your course, and go from there.

It's amazing how much power frameworks like Laravel give someone like me who considers themselves to not be a strong developer the ability to do so much.

1 Answer

Raymond Wach
Raymond Wach
7,961 Points

I'm definitely not an advanced developer, but it sounds like the problem you are describing very nicely fits the model of having a backend database such as MySQL or PostgreSQL and some way of generating content from dynamic queries on the database (using a combination of server-side code to talk to your database and AJAX client-side). Doing a quick search of the library, I came across this course: Using PHP with MySQL that might interest you. You mention Ruby on Rails, but it doesn't sound like you really need something as heavy-weight as Rails to meet your needs. As long as you can keep your data in table form, it makes sense to use some sort of RDBMS and SQL, and until you need to do something significantly more complex than straightforward SQL queries, you're better off keeping the server-side code as thin as possible.

Kevin Korte
Kevin Korte
28,149 Points

Hi Raymond, Thanks for the reply. I've actually done the PHP and MySQL course, and the database foundations course, as well as most of the Wordpress courses.

My big concern is database management. Something I'm quite curious is what everyone thinks if I had a machine as an entry in a database, and attached to that machine was the 300-500 reference ids to unique pieces of data, and all of this had to be queried and looped through, is that too much to ask? I don't know.

If I attach data to a machine inside the database, I'll have the same data repeated a lot which I know is not optimal, especially when we have unique and foreign keys to use.

I'm not sure how else to structure the data in a database besides my idea of having each data piece having a unique key, and attaching that key to all machines that it belongs too.

The reason I'm looking at a framework like Laravel or Rails is because of my plans for growing the site. User accounts, allowing trusted users to edit, update, or modify data, relating similar machines, possibly querying part numbers to return a list of all machines it fits, selling good used parts, technical documents section, and possibly a forum/QA section, it all seems to me that a framework can provide a lot of the heavy lifting for these features.

Here is what I have now. Machine Cheat Sheet

Just not happy with it's scalability.

Raymond Wach
Raymond Wach
7,961 Points

Okay Kevin Korte, it looks like you have two separate concerns here: scaling your data and building out features to your site. These are very common concerns and for the latter, I think you are right to look at a framework such as Rails (I'm not familiar with Laravel). As to the former, I don't really have the experience to speak with any kind of authority, but you should be able to find performance metrics and comparisons published online that will give you an idea of the amount of data and transactions a prospective data store can handle before performance needs to be a concern.

Kevin Korte
Kevin Korte
28,149 Points

Hi Raymond, I did some thinking over the weekend on your comments, and I think I'll be okay as far as SQL queries go, for a long time anyway. Actually found an interesting article about how Facebook executes so my MySQL queries and still maintains a reasonably responsible query. Did go into much details for the security concerns, but still interesting none the less. Thank you my friend.