Welcome, Guest. Please Login or Register.
April 27, 2025, 06:43:32 PM
Home Help Search Log in Register
News: SMF is the next generation in forum software, almost completely re-written from the ground up, make sure you don't fall for cheap imitations that suffer from feature bloat!

YaBB SE Community  |  General Category  |  Feedback  |  questions « previous next »
Pages: [1] Reply Ignore Print
Author Topic: questions  (Read 1162 times)
groundup
Disciple of Joe, Head Cleric
Mod Team
YaBB God
*****
Posts: 2983


Error 309: Please notify the administrator of this

WWW
questions
« on: November 18, 2002, 02:11:06 AM »
Reply with quote

Why does deletedby have a -1 in instant_messages?

why do we use the unix timestamp to store stuff in mysql when mysql is easier to read, a smaller number, and just as useful?

should "Guest" have a place in log_boards, log_topics, etc?
Logged

http://www.fastfinancialfreedom.org - financial freedom is a myth
http://www.fastfinancialfreedom.org - financial freedom is a myth
http://www.fastfinancialfreedom.org - financial freedom is a myth
fastfinancialfreedom.org
Joseph Fung
Global Moderator
YaBB God
*****
Posts: 4512


Keep smiling: it makes others nervous.

WWW
Re:questions
« Reply #1 on: November 18, 2002, 03:00:53 AM »
Reply with quote

Ok - re. the deletedBy, if I remember right -1 means it hasn't been deleted by anyone.  0 means it was deleted by the sender and 1 means it was deleted by the recipient.

The reason for this is that it means any given IM message only needs to be stored once, and we can use that flag to decide when it should be shown or removed from the DB.

We are using the unix time stamp because PHP's time functions use the unix time stamp. If we use the MySQL datte and tiem field it would have to do a conversion every time we wanted to do something with the timestamp.  Additionally, using a unix timestamp means were not restricted to a mysql database.  it leaves us open for future development.
Logged

groundup
Disciple of Joe, Head Cleric
Mod Team
YaBB God
*****
Posts: 2983


Error 309: Please notify the administrator of this

WWW
Re:questions
« Reply #2 on: November 18, 2002, 04:07:07 AM »
Reply with quote

thank you, why didn't you just use 2 instead of -1? it is 1 less byte and you can use unsigned attribute?
Logged

http://www.fastfinancialfreedom.org - financial freedom is a myth
http://www.fastfinancialfreedom.org - financial freedom is a myth
http://www.fastfinancialfreedom.org - financial freedom is a myth
fastfinancialfreedom.org
Joseph Fung
Global Moderator
YaBB God
*****
Posts: 4512


Keep smiling: it makes others nervous.

WWW
Re:questions
« Reply #3 on: November 18, 2002, 02:13:37 PM »
Reply with quote

Excuse me? No - it doesn't use one less byte.

If it were stored in a text field then yes - you would be right.  But currently (I'm pretty sure - I could be wrong) it's using an integer field.

Also, it takes the same number of bits to store a 2 as it does to store a -1.

In Binary, a two is 10 while a -1 is stored as 11 (note, this is assuming the machine is designed to store it in 2's complement form - which almost all are)

So, the only time using 2 instead of -1 would yeild any benefit is if we were using text fields, which wouild render "unsigned" useless.  And it would be pointless to do that as we'd be using a full 8bits to store each number - which is what is happening now anyway.

If you want, I can give you a more detailed explanation if I did that too quickly.
Logged

groundup
Disciple of Joe, Head Cleric
Mod Team
YaBB God
*****
Posts: 2983


Error 309: Please notify the administrator of this

WWW
Re:questions
« Reply #4 on: November 19, 2002, 03:46:08 AM »
Reply with quote

I didn't check but I thought I saw it using something other than tinyint(1), which would be boolean. Wouldn't tinyint(1) unsigned mean from 0-9? does the 1 signify a digit/place/character?
Logged

http://www.fastfinancialfreedom.org - financial freedom is a myth
http://www.fastfinancialfreedom.org - financial freedom is a myth
http://www.fastfinancialfreedom.org - financial freedom is a myth
fastfinancialfreedom.org
Joseph Fung
Global Moderator
YaBB God
*****
Posts: 4512


Keep smiling: it makes others nervous.

WWW
Re:questions
« Reply #5 on: November 19, 2002, 04:53:42 PM »
Reply with quote

Quote from: groundup on November 19, 2002, 03:46:08 AMI didn't check but I thought I saw it using something other than tinyint(1), which would be boolean. Wouldn't tinyint(1) unsigned mean from 0-9? does the 1 signify a digit/place/character?
tinyint(1) would have one of two meanings.

The first is how many bits.  If this is what it means, tinyint(1) would, indeed represent 1 bit - which would be boolean, and therefore useless in this circumstance (meaning two values is insufficient - we need 3 values for this system).  I'm fairly certain, however, that in mysql, tinyint is always restricted to 1 byte lengths - which is 8 bits.

Likely the 1 refers to how many bytes - specifically with respect to how many ascii characters it can contain.

I think you are misunderstanding the way the data is stored.  If it's storing the ascii value of a number, it's actually storing 0x30   <digit> for each character (i.e. 36 would be stored as 0x33 0x36 taking up two bytes).  If it's storing the integral value, it stores the value.  So 36 would be stored as 0x24 taking up one byte.

Essentially, if the field is a tinyint, it's as efficient as it's going to get.
Logged

Greg Robson
Training to be like Joseph
YaBB SE Developer
YaBB God
*****
Posts: 1459


Hello!

ICQ - 81390136 WWW
Re:questions
« Reply #6 on: November 20, 2002, 10:21:52 AM »
Reply with quote

The 1 in tinyint(1) refers to the maximum number of characters to display. It has no effect on how the data is stored. :)

FYI
tinyint, 1 byte, -127 - 128 or 0 - 255
smallint, 2 bytes, -32768 - 32767 or 0 - 65535
mediumint, 3 bytes, -8388608 - 8388607 or 0 - 16777215
int, 4 bytes, -231 ... 231-1 or 0 ...232-1
bigint, 8 bytes, -263 ... 231-1 or 0 ...264-1
Logged

You can't have everything... where would you put it? -- Steve Wright
Pages: [1] Reply Ignore Print 
YaBB SE Community  |  General Category  |  Feedback  |  questions « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.030 seconds with 16 queries.