Re: storing deleted appoitments
Posted by: Rick James
Date: January 26, 2015 11:53PM

How to store a boolean...

deleted TINYINT UNSIGNED NOT NULL COMMENT '0=false=active, 1=true=deleted'
WHERE deleted
WHERE NOT deleted
(BOOL works the same)

active TINYINT UNSIGNED NOT NULL COMMENT '0=false=deleted, 1=true=active'
WHERE active
WHERE NOT active
(BOOL works the same)

status ENUM('deleted', 'active') NOT NULL
WHERE status = 'deleted'
WHERE status = 'active'

status CHAR(1) NOT NULL CHARSET=ascii COMMENT 'D=deleted, A=active'
WHERE status = 'D'
WHERE status = 'A'

Each takes 1 byte of storage.
Performance of each is virtually identical.
So, think about how you want to phrase the WHERE clause.

If you have more than two values, BOOL fails and TINYINT needs a number:
WHERE deleted=0 -- no
WHERE deleted=1 -- yes
WHERE deleted=2 -- maybe

The `status` examples expand to more than 2 choices in an obvious way. However, I would not go beyond a few dozen values; it gets cumbersome (as would TINYINT).

Options: ReplyQuote


Subject
Written By
Posted
January 22, 2015 09:44AM
January 23, 2015 01:27PM
January 23, 2015 05:58PM
Re: storing deleted appoitments
January 26, 2015 11:53PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.