Jump to content

Active Field In Database


son

Recommended Posts

Setting up a table where the content is only displayed on web page once it has been quality-checked:Is it ok to have a field 'active', which is either '0' for not active and '1' for active?What is the standard way of doing that?Son

Link to comment
Share on other sites

That's the way I do it. I use unsigned tinyint(1) for that, if your DBMS supports it you could also use bit or boolean.
What does unsigned exactly mean? Have used it before, but never really understood the implications...Son
Link to comment
Share on other sites

Unsigned means the value cannot be negative. Unsigned assumes a positive value. Numbers in computers are represented using bits. So if we have a 4 bit number, the 4 bits have a max value of 15, so it goes from 0-15 for 4 bits, if it is unsigned. If it is signed, then it uses the first bit for positive/negative, and the other 3 bits for precision. So I use u for unsigned and s for signed:u1011 = 11 (eleven)s1011 = (negative)011 = -3u1111 = 15s1111 = (negative)111 = -7s0111 = (positive)111 = +7So an unsigned 4-bit number can go from 0-15, and a signed 4-bit number can go from -7 to +7.

Link to comment
Share on other sites

Unsigned means the value cannot be negative. Unsigned assumes a positive value. Numbers in computers are represented using bits. So if we have a 4 bit number, the 4 bits have a max value of 15, so it goes from 0-15 for 4 bits, if it is unsigned. If it is signed, then it uses the first bit for positive/negative, and the other 3 bits for precision. So I use u for unsigned and s for signed:u1011 = 11 (eleven)s1011 = (negative)011 = -3u1111 = 15s1111 = (negative)111 = -7s0111 = (positive)111 = +7So an unsigned 4-bit number can go from 0-15, and a signed 4-bit number can go from -7 to +7.
Thanks a lot. Cannot believe how good your explanation is and how easy to understand. Having had different definitions in the past I always assumed it is something really complicated... Again, thanks for a great help!Son
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...