ejabberd - Comments for "Database Design of ejabberd" https://www.ejabberd.im/node/3139 en Also... for lusername https://www.ejabberd.im/node/3139#comment-53404 <p>Maybe I again missed the point... but for me it looks quite strange</p> <p>family text NOT NULL,<br /> lfamily varchar(250) NOT NULL</p> <p>So, I wonder, If lfamily is just same, as family, but in lowercase... why they have a different types (varchar upto 250, and text)?</p> <p>Text types can be very big (much larger than 250 chars), and have some differencies against varchars...</p> <p>Also... for me is strange, why there is necessity in "same field, but in lowercase"... ?</p> <p>What is need in "SELECT lusername", if we can do just "SELECT LOWER(username)"</p> <p>AFAIK, "LOWER" is even SQL-standard string function....</p> Wed, 09 Jul 2008 16:31:57 +0000 philipj comment 53404 at https://www.ejabberd.im Maybe it help somebody https://www.ejabberd.im/node/3139#comment-53403 <p>As far as I know, Primary Key on Mysql on char field actually do following:</p> <p>1. If there is a record, for example... "Philip" :) You can't store same value in that field at another record, or change (UPDATE) another record to "Philip". Database will show an error. It's usefull if You want to be absolutely shure, that records (in that column) are unique on DB-level.<br /> There is no way to enter to different records two similar values at Primary Key field.</p> <p>Some info -</p> <blockquote><p> A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a new row with a key that matches an existing row. </p> <p>A PRIMARY KEY is a unique index where all key columns must be defined as NOT NULL. If they are not explicitly declared as NOT NULL, MySQL declares them so implicitly (and silently). A table can have only one PRIMARY KEY. </p> <p>If a PRIMARY KEY or UNIQUE index consists of only one column that has an integer type, you can also refer to the column as _rowid in SELECT statements </p></blockquote> <p>2. If You use statements like</p> <div class="codeblock"><code>SELECT f1, f2 FROM table1 WHERE prikeyfield=&quot;Philip&quot;<br />SELECT f1, f2 FROM table1 WHERE prikeyfield=&quot;Phil%&quot;<br />SELECT f1, f2 FROM table1 INNER JOIN table2 ON prikeyfield=table2keyfield</code></div> <p>It will be MUCH faster if prikeyfield declared as Primary Key.</p> <p>So... If these two reasons is important for You, You shold use it... if no - You can omit declare Primary Key... AFAIK</p> Wed, 09 Jul 2008 15:55:34 +0000 philipj comment 53403 at https://www.ejabberd.im Dear badlop, Thanks for your https://www.ejabberd.im/node/3139#comment-53402 <p>Dear badlop,</p> <p>Thanks for your reply.<br /> Let me see see if it works.</p> <p>Best regards,<br /> day</p> Wed, 09 Jul 2008 08:00:04 +0000 day comment 53402 at https://www.ejabberd.im Lowercase https://www.ejabberd.im/node/3139#comment-53397 <div class="quote-msg"> <div class="quote-author"><em>day</em> wrote:</div> <p>1. Do anyone know what is the "l" in "lusername" meant?</p></div> <p>Looking at the source code, lfamily is the lowercase version of family. So, if family = "MtCan", then i bet lfamily = "mtcan". The same applies to all the other L+variable.</p> <div class="quote-msg"> <div class="quote-author"><em>day</em> wrote:</div> <p>2. Will I have any problem if I remove the PRIMARY KEY flag in the "lusername"</p></div> <p>I think that was added for some good reason. If there weren't a reason, it wouldn't be there, right? You can remove and try, but later don't complain if something breaks :P</p> Tue, 08 Jul 2008 23:20:19 +0000 mfoss comment 53397 at https://www.ejabberd.im