Jump to content

Reusing columns for different items


Recommended Posts

I have a mysql table of items and was wondering if it would be to confusing to combine the columns used for the different “non-repeating info” that items had.


Instead of having columns for the number of bathrooms, boat length, rv length and camper length have one column called something like num1.


I've always heard that you should name columns in a way that associates with the column info, but if I combine columns I just have to add 18 columns, if I don't combine them I have to add 50 plus columns.


Or .. even though the data is non repeating go ahead and make tables for the info for realestate, boats, autos, rv's and on and on.


Just looking for some ideas


Link to comment
Share on other sites

It seems to me you could keep it in a single table with fewer columns if you think of your data a bit differently. Example:


Column       Object Type     Number of Baths     Length


                      Car                    0                             9

                      RV                      1                             30

                      Boat                    2                          120


No reason to think of car length, boat length, and rv length as different types of data unless I misunderstand.

Link to comment
Share on other sites

Baths, in a car? That makes no sense.

Also, what if you wanted to add the mast height of sailboats, or the tire dimensions for the cars? You'd end up with an unholy mess of fields, most of which makes no sense to have in any one of the rows.


No, do what Barand and Jessica suggested, and use a proper database design for this.

Link to comment
Share on other sites

Of course, Christian is right - mast height or number of wheels doesn't fit into a single table. I wasn't thinking clearly there. However, I still thinnk that car length, boat length, and vehicle length shoudl be generalized to vehicle lenght.


Appologies for the poorly thought out post.

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.

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.