<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1041154" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1041154</link>
    <description></description>
    <language>en</language>
          <item>
    <title>Yes, but group by doesn&#039;t</title>
    <link>https://www.webmaster-forums.net/web-database-development/grouping-individual-user-data-one-table#comment-1234052</link>
    <description> &lt;p&gt;Yes, but group by doesn&#039;t change the amount of rows mysql will query. I was wanting to minimise the actual searching for.&lt;br /&gt;
So instead of searching through 100,000 rows, I could group things within the DB structure, so it only needed to search thorugh say 20,000 rows for a specific group of things.&lt;/p&gt;
&lt;p&gt;Thanks anyway&lt;/p&gt;
 </description>
     <pubDate>Thu, 02 Oct 2008 09:31:27 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1234052 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>To present things in groups,</title>
    <link>https://www.webmaster-forums.net/web-database-development/grouping-individual-user-data-one-table#comment-1234048</link>
    <description> &lt;p&gt;To present things in groups, we first rely on SQL to group the data before it.This is done with a GROUP BY or ORDER BY clause.&lt;/p&gt;
 </description>
     <pubDate>Thu, 02 Oct 2008 06:52:36 +0000</pubDate>
 <dc:creator>domain</dc:creator>
 <guid isPermaLink="false">comment 1234048 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>I am not sure if i am</title>
    <link>https://www.webmaster-forums.net/web-database-development/grouping-individual-user-data-one-table#comment-1230178</link>
    <description> &lt;p&gt;I am not sure if i am understanding you correctly and i am by no means an expert on Databases or profile type site but:&lt;br /&gt;
comment table is auto incremented and numbered maybe 3 fields:&lt;br /&gt;
Comment_number, COmment, Comment_added_by_user&lt;/p&gt;
&lt;p&gt;users table contains additonal fields:&lt;br /&gt;
user_comments--&amp;gt; containing comma seperated values of each of the users comments that they made (Ex. 1,1000,3500)&lt;br /&gt;
comments_by_other_users--&amp;gt; containing comma seperated values of each of comments that were posted by other users&lt;/p&gt;
&lt;p&gt;Now when a users profile is loaded you can fetchrow or whatever for just those specific comments and no need to search the DB. Same way When you want to show the comments_by_other_users. Just seperate the comma seperated value with a script and get those comments directly. ALso you can get Comments_added_by_user if you want to show what user posted what comment.&lt;br /&gt;
I hope this helps.&lt;/p&gt;
 </description>
     <pubDate>Fri, 16 May 2008 06:41:44 +0000</pubDate>
 <dc:creator>rhino-matic</dc:creator>
 <guid isPermaLink="false">comment 1230178 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Thanks for the info peeps.
I</title>
    <link>https://www.webmaster-forums.net/web-database-development/grouping-individual-user-data-one-table#comment-1230167</link>
    <description> &lt;p&gt;Thanks for the info peeps.&lt;/p&gt;
&lt;p&gt;I read that article on normalisation before (that exact one actually), and really don&#039;t see I can do anything else.&lt;/p&gt;
&lt;p&gt;Ok, I seem to have two topics in this thread (my bad).&lt;br /&gt;
So I&#039;ve continued the discussion of the 20 tables and 40 fields in another thread.&lt;br /&gt;
I used the members area as I provided more info that I&#039;d like to keep a little more private...&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.webmaster-forums.net/members-only/continuedgrouping-individual-user-data-one-table&quot; title=&quot;http://www.webmaster-forums.net/members-only/continuedgrouping-individual-user-data-one-table&quot;&gt;http://www.webmaster-forums.net/members-only/continuedgrouping-individua...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;.&lt;br /&gt;
.&lt;br /&gt;
.&lt;/p&gt;
&lt;p&gt;Continuing this thread about having multiple rows in one table for the same USERNAME.&lt;/p&gt;
&lt;p&gt;Say member &quot;John&quot; has had 3 other members comment on his profile page.&lt;br /&gt;
So in table &quot;profile_commnets&quot; John has 3 rows.&lt;/p&gt;
&lt;p&gt;Take a 1,000 members with an average of 3 comments per member, that&#039;s 3,000 rows in table.&lt;br /&gt;
$username = John;&lt;br /&gt;
When I query - select * where username=$username - I only want 3 rows, but mysql has to tral through 3,000&lt;/p&gt;
&lt;p&gt;John&#039;s 1st comment might be row id 100, then his second is row id 1,200, then his third is row id 2,500&lt;br /&gt;
I was wanting a solution to avoid mysql having to trawl through 3,000 rows to find only three. But not knowing how indexes work I don&#039;t know if there will be any benefit, and dont know any other solutions. &lt;/p&gt;
&lt;p&gt;As I understand it, an index would take the username &quot;John&quot; (as the index reference) and relate that reference to the ID in the table profile_comments, so &quot;100&quot; &quot;1,200&quot; and &quot;2,500&quot; (Johns comments row ID&#039;s)&lt;/p&gt;
&lt;p&gt;So it goes into it&#039;s index list and gets all for &quot;John&quot;. But there are 1,000 other members with comments stored in this index, so surely that wouldn&#039;t help any. Yes it&#039;s a third less, but with the having to search index, then goto actual table with found ID&#039;s and the fact it has to update/delete the index I don&#039;t see whre it would help.&lt;/p&gt;
&lt;p&gt;Sites such as forums must have tens of thousands of rows with duplicate username entries for each post they make.&lt;br /&gt;
Like I have 360 rows in this sites DB, that has to be queried when I select &quot;my topics&quot;.&lt;/p&gt;
&lt;p&gt;Perhaps I just have to simply store them all and let mysql do its job?&lt;/p&gt;
 </description>
     <pubDate>Thu, 15 May 2008 15:50:14 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1230167 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Another question.
I have the</title>
    <link>https://www.webmaster-forums.net/web-database-development/grouping-individual-user-data-one-table#comment-1230151</link>
    <description> &lt;blockquote&gt;&lt;p&gt;Another question.&lt;br /&gt;
I have the need to store in 40 fields of data in a table. I need 20 of these tables.&lt;br /&gt;
70% of the fields will be yes or no, the other 30% varchars of about 12 chars average&lt;br /&gt;
Is that ok or is it better to make three tables with 13 fields in each?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The only meaningful answer to this is: &lt;a href=&quot;http://www.google.com/search?client=opera&amp;amp;rls=en&amp;amp;q=database+normalisation&amp;amp;sourceid=opera&amp;amp;ie=utf-8&amp;amp;oe=utf-8&quot;&gt;normalise it&lt;/a&gt;! As teammatt3 pointed out, it seems like you&#039;re prematurely optimising, moreover you&#039;re getting paranoid about what&#039;s right and wrong. &lt;/p&gt;
&lt;p&gt;Generally, if you&#039;re going to sort by a field often, index it! And for the future: ensure you&#039;ve got the &lt;a href=&quot;http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html&quot;&gt;MySQL slow log&lt;/a&gt; switched on, that can help you find queries which are running slowly.&lt;/p&gt;
&lt;p&gt;As a rough guide, 40 fields of booleans sounds rather a lot. Sounds like you need a &#039;settings&#039; table with a many-to-many relationship with your users table. Also, throwing around lots of tables is a bad sign. 20 tables? For what? Each table should relate to &lt;em&gt;something&lt;/em&gt;, and should &lt;strong&gt;never&lt;/strong&gt; be arbitrarily split to reduce the number of fields in each one.&lt;/p&gt;
 </description>
     <pubDate>Thu, 15 May 2008 07:13:53 +0000</pubDate>
 <dc:creator>JeevesBond</dc:creator>
 <guid isPermaLink="false">comment 1230151 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>If &quot;user_to&quot; is part of the</title>
    <link>https://www.webmaster-forums.net/web-database-development/grouping-individual-user-data-one-table#comment-1230129</link>
    <description> &lt;p&gt;If &quot;user_to&quot; is part of the primary key, it is already being indexed. &lt;/p&gt;
&lt;p&gt;If a table is being written to a lot more than it&#039;s being read from, an index isn&#039;t really a great thing to have. Like you said, the index has to be updated every time a row is inserted or deleted. &lt;/p&gt;
&lt;p&gt;An index works best on columns with a high level of selectivity. That is, the uniqueness of the data in that column. A primary key is always indexed because it is alway unique. To find the selectivity of the column, divide the the distinct values contained in the data set by the total number of records in the data set. The larger the quotient, the better an index will perform on that column. &lt;/p&gt;
&lt;p&gt;I&#039;m a little concerned that you&#039;re prematurely optimizing your SQL and database structure. It&#039;s good to keep in mind what performance problem you may have in the future, but throwing indexes on every column because you can, is not always the best idea, and it could backfire on you. &lt;/p&gt;
&lt;p&gt;P.S. I recommend you get a copy of Pro MySQL by Michael Kruckenberg and Jay Pipes. It&#039;s a great read, and a great reference to have. It has a chapter on profiling and that&#039;s something you&#039;ll want to do so you &lt;em&gt;know&lt;/em&gt; what you&#039;re doing to the structure is increasing the performance.&lt;/p&gt;
 </description>
     <pubDate>Wed, 14 May 2008 17:25:46 +0000</pubDate>
 <dc:creator>teammatt3</dc:creator>
 <guid isPermaLink="false">comment 1230129 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>I read that indexing can</title>
    <link>https://www.webmaster-forums.net/web-database-development/grouping-individual-user-data-one-table#comment-1230124</link>
    <description> &lt;p&gt;I read that indexing can result in performance drop in certain circumstances as MYSQl has to create, update and delete data to the index list it stores.&lt;br /&gt;
So it&#039;s six for one method and half a dozen for the other.&lt;br /&gt;
I presume that would of course depend on the data stored,  how many rows in total and how many rows are actually to be grouped.&lt;/p&gt;
&lt;p&gt;As for the second question.. the rows are not related to each other at all within the table as each row is for one user only.&lt;br /&gt;
The data between fields within one row is obviously not related as it&#039;s different data.&lt;/p&gt;
 </description>
     <pubDate>Wed, 14 May 2008 13:29:42 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1230124 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>This is what an index will</title>
    <link>https://www.webmaster-forums.net/web-database-development/grouping-individual-user-data-one-table#comment-1230121</link>
    <description> &lt;p&gt;This is what an index will do.  Relational databases have very efficient index structures. If you ensure you have an index on user_to and your table has 10,000 rows, then instead of having to check all 10,000 rows individually it may only have to check 4 or 5 rows, as it is (depending on  the low-level implementation of the index) navigating down a tree to the right bunch of data instead of stupidly checking every row one by one.&lt;br /&gt;
The second question cannot be answered without some context.  Are the fields of data logically related? Do they group together naturally into a table?&lt;br /&gt;
Do you think that splitting into small tables will help performance? - the answer to that is likely to be no.&lt;/p&gt;
 </description>
     <pubDate>Wed, 14 May 2008 12:59:32 +0000</pubDate>
 <dc:creator>blater</dc:creator>
 <guid isPermaLink="false">comment 1230121 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
