Jump to content

Recommended Posts

It is normalized but its weather i should split some of my tables up to smaller tables.

 

if, as you said... it's normalized... then are you trying to split tables due to the number of records? or you really are not sure if you data structure is correct (and normalized)?... please clarify

Link to comment
https://forums.phpfreaks.com/topic/234304-more-or-less-fields/#findComment-1204453
Share on other sites

It is normalized but its weather i should split some of my tables up to smaller tables.

 

if, as you said... it's normalized... then are you trying to split tables due to the number of records? or you really are not sure if you data structure is correct (and normalized)?... please clarify

I think the question is about whether to split a (normalized) table with a couple dozen columns into a couple smaller (slightly less normalized) tables. Like if you had a table with columns A-Z, is there any worth to splitting it into a table1 with A-M and a table2 with N-Z (with a 1-to-1 relationship between them).

Link to comment
https://forums.phpfreaks.com/topic/234304-more-or-less-fields/#findComment-1204619
Share on other sites

It is normalized but its weather i should split some of my tables up to smaller tables.

 

if, as you said... it's normalized... then are you trying to split tables due to the number of records? or you really are not sure if you data structure is correct (and normalized)?... please clarify

I think the question is about whether to split a (normalized) table with a couple dozen columns into a couple smaller (slightly less normalized) tables. Like if you had a table with columns A-Z, is there any worth to splitting it into a table1 with A-M and a table2 with N-Z (with a 1-to-1 relationship between them).

 

exactly. So to sum up again is a table with large number of fields (forget number of rows) better over multiple tables with less fields... which im not sure why everyone is complicating this with normalization when it has no relationship what ever to it.

Link to comment
https://forums.phpfreaks.com/topic/234304-more-or-less-fields/#findComment-1205081
Share on other sites

In my experience the only reasons that I've seen to do that (1-1 relationship) is to avoid null/optional columns (empty space) , to implement some kind of sub-typing, or if the table contains fields that are only used for a certain subset of the records.

 

In case of space concerns,  I would not bother and live with the empty space. I believe that the hassle it can cause to the development process simply isn't worth it (more "complex" queries/joins), space is cheaper than programming time. For sub-typing or tables with fields identified clearly as a subset most of the time split the model in 1-1 relationship make sense . But, then again, the decision to implement something like you are asking for depend of what exactly are you modeling and your business rules.

Link to comment
https://forums.phpfreaks.com/topic/234304-more-or-less-fields/#findComment-1205888
Share on other sites

I would say that it depends on what is stored in the tables.

 

if you are storing text fields that will hold a body of text, then you may want to spit it up. For example:

 

You have have database that holds emails, you probably would want one table to store the subject, and one table to store the body. Why? Lets say you have the traffic of Gmail, a text data type has an unknown length, so MySql doesn't have the best idea of where the text ends, so now it has to find start and end points of the data of the text that you won't even use, just to display a list of email subjects. moving the text (body) to a second table, mysql no longer worry about the body of the document just to get subjects.

 

Like a text book (without an index), it would be fairly easy to find all the chapters without having to skim 50 pages to find the end of each chapter if the chapters were in one book with a page number saying where the chapter is in the second book you could get there insanely faster. (no sure on how well this reference is, but it makes sense to me :) )

 

This is the same with varchar vs char, varchar usually takes up less space, but char is faster in the long run.

 

Another think you may want to do is learn about inet_aton and inet_ntoa, which converts ip addresses to from 16 bytes to 8 bytes that will reduce a table significantly in size, and makes it about 25 - 50 faster I would say.

Link to comment
https://forums.phpfreaks.com/topic/234304-more-or-less-fields/#findComment-1206189
Share on other sites

Like a text book (without an index), it would be fairly easy to find all the chapters without having to skim 50 pages to find the end of each chapter if the chapters were in one book with a page number saying where the chapter is in the second book you could get there insanely faster. (no sure on how well this reference is, but it makes sense to me :) )

The only book analogy for your idea that I can think of is a novel where every page is in a different book. Sure, you know the length of each book, but you have to use a bunch of them to get the final story.

MySQL stores the length of variable-length text fields. There is no guesswork. It doesn't have to scan for a terminating NUL. And depending on the data type, the data isn't actually stored inline in the table with everything else.

 

In my experience, these kinds of "optimizations" are best left to the people who write the database system. Just use it normally without any fancy "can I develop something convoluted to maybe gain a little bit of $metric" questions.

Link to comment
https://forums.phpfreaks.com/topic/234304-more-or-less-fields/#findComment-1207060
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.

Guest
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.