Jump to content
Larry Ullman's Book Forums
MikeMikeMike

One Size_Id Means Only Comes In One Size?

Recommended Posts

I am using PHP 5.26 nd mysql 5.0

 

This question was originally posted at the bottom of another thread, but as it`s actually a new question, I thought it better to post a new thread (so I erased the question from the other thread)

 

This may be an easy question, but I found my assumption to be rather illogical (as I will explain below) so I thought I would ask.

 

Why, in the specific_coffees table, does each coffee only have one size_id?

 

Does that mean that each coffee is only available in one size? If not, which rationale did Larry use to assign a specific size_id to a specific coffee?

 

The reason why I am having difficulty is the following. I find it weird that each coffee would only come in one size. Why wouldn`t each coffee be available in every size? Is this just a quirk related to Larry`s imaginary coffee store?

 

So please explain, does the fact that each specific_coffee only has one size id mean that it only comes in one size?

 

 

This question is sort of tangentially related to my other question, what is the rationale for choosing keys. I understand the basic idea of keys to connect tables, but I find (probably due to my limited understanding) the use of the size_id a bit counterintuitive ( because, as stated above, it suggests to me only one size is available for each coffee), unless this store really only does each coffee in one of five sizes.

Share this post


Link to post
Share on other sites

I can't speak for larry but my experience with tutorials like the two sites in Larry's book is that they are just basic examples to show enough to get you up to speed on how to create sites like the two examples. There is a lot of things left out, on purpose.

 

If you want to have more than one size for your coffee store for each coffee go ahead and add more sizes, with the information taught it is very easy to add and expand these two site examples to do a lot more. Though that is entirely up to you. You will never find tutorials that are all inclusive, it goes out of bounds of the instructional nature of the teaching. It is left up to the student to expand and take the basic site beyond what it is.

 

There are a lot of things that Larry does that I personally do not code that way. I went through the book up to the point I needed information and did it exactly how Larry has it in the book and in the downloaded examples. Once I understood what was going on I was able to alter the code to the way I needed it to work and merged in with my own projects. A lot of things was not in the book or here on the forum, I had to go else where to find examples and further instruction but in the end I was able to do what I needed.

 

Those are my thoughts, but for the specific reasoning and thinking behind why Larry did things they way he did, Larry will need to reply specifically.

  • Upvote 1

Share this post


Link to post
Share on other sites

Thanks for your input Terry. I totally understand that the features of the store might be limited in an example store. I just wanted to clarify if that's actually what's happening here, because I'm trying to learn the SQL as we go.

 

Elsewhere in the forum Larry has said that each coffee was available in 5 sizes. The one size_id for each specific coffee seemed to contradict that.

Share this post


Link to post
Share on other sites

Look at page 166 Figure 7.3 for diagram of the Product Tables.

 

Sizes are located in a separate table and linked to the specific_coffee table.

 

On page 195 section 5 at bottom of page and then continue to page 196 Larry explains what is happening with sizes and how they relate to the coffee products.

 

As to specific how's of linking the tables, that goes beyond the scope of this book and assumes you know this information already.

 

Why, in the specific_coffees table, does each coffee only have one size_id?

 

Walk into any coffee shop, star bucks or what have you and you will see that different sizes are at different prices, which makes them a separate product.

On page 196 he says as much but also adds the equation limited supplies of products.

 

Where he is calling this information and putting the sizes together is described starting at the bottom of page 196 under the section Looking at the Stored Procedure Queries. You will need to look through the rest of the book yourself to find specific code using these within the site two example.

 

 

 

Thanks for your input Terry. I totally understand that the features of the store might be limited in an example store. I just wanted to clarify if that's actually what's happening here, because I'm trying to learn the SQL as we go.

 

Elsewhere in the forum Larry has said that each coffee was available in 5 sizes. The one size_id for each specific coffee seemed to contradict that.

  • Upvote 1

Share this post


Link to post
Share on other sites
As to specific how's of linking the tables, that goes beyond the scope of this book and assumes you know this information already.

 

This is of course Larry's choice, but as a bit of feedback for him, I find it a little odd.

 

For example, Larry spends quite a bit of time explaining very simple PHP concepts and code that he explained in his first two books. However, in those other books, he didn't (to my recollection) create more involved databases where we got exposure to the best practices and strategies behind linking tables, which, in my opinion, requires more explanation than some of the simple php in this book.

 

Therefore, he seems (in my opinion) to assume readers know the more difficult information (which requires actual thought process) while he spends some time explaining simple concepts.

 

That's just feedback he can consider for future editions, if he likes

Share this post


Link to post
Share on other sites

MikeMikeMike,

 

I can somewhat agree with you on that. I have also ran into situations where I felt the same way and it can be frustrating.

 

However, given the nature of your questions, I feel like you are having trouble with some of the fundamental concepts of database design. I don't mean to steer you away from buying Larry's books (although you mentioned that you already had a few of them), but maybe you might consider supplementing them by enrolling in a web programming/database class at a local community college. The knowledge/experience you would gain would be invaluable!

  • Upvote 1

Share this post


Link to post
Share on other sites

Actually, I misunderstood the database. It`s not even true that each coffee is available only in one size, so Larry wasn`t created limited functionality (i.e. each coffee only in one size) for teaching purposes This discussion was moot.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...