+ 4

What is the meaning of "flag" in databases ?

what are "flags" used for ?

12th May 2017, 12:44 AM
zakaria kasmi
zakaria kasmi - avatar
3 Answers
+ 1
Anytime I or others I work with use a "flag" it's as simple as a variable or field set as 1. Then you can have a conditional that looks at that variable or field and if it equals 1, it runs or shows code or doesn't...pending what It's used for. If you have a field in your database called "hide" & you pull multiple results but you have the flag to hide one, you can have code that looks for that & it won't display that result. Nothing crazy.
12th May 2017, 1:46 AM
Damien Lucchese
Damien Lucchese - avatar
0
It can also refer to 'flagged for deletion' until the deletion is committed to the database.
12th May 2017, 3:09 AM
Ryan Martin
Ryan Martin - avatar
- 1
It's mainly used to mean any Boolean variable, that is, a variable that can only hold the values "true" or "false" (or also "null", in case of SQL). Normally it represents the answer to whether a certain attribute is set. In the examples above (@Damien) you could have a column named "is_hidden" in each record. Or (@Ryan) a column called "is_deleted". Generally speaking, the use of the term "flag" to mean "true or false" is found beyond SQL, too.
12th May 2017, 5:22 AM
Álvaro