Best way to store status and type of an order in database
Answered
Holland Lop posted this in #help-forum
Holland LopOP
I'm wondering if there is a "best way" to store status and order type in the database. For example in my case,
I have an order, which will have a type of
Back in my workplace, I saw my developer team is using integers to store these things, for example
I have an order, which will have a type of
regular, or express. The order will also have a status of something like order_created, in_progress, order_finished, canceled.Back in my workplace, I saw my developer team is using integers to store these things, for example
1 for order_created, -1 for canceled and something like that. I'm wondering if there's any downside of just storing it as string instead of integers, as it is more readable.Answered by B33fb0n3
Great to hear, that you found a a way. Just to solved this post with this message:
Currently you don't need to use linkedlist via numbers in your orders. you decided to use enums instead, to keep track of the order fulfillment
Please mark solution
Currently you don't need to use linkedlist via numbers in your orders. you decided to use enums instead, to keep track of the order fulfillment
Please mark solution
9 Replies
The downside I currently think about is, that you can’t compare strings in a linked list. So when you have your order status in numbers and you have a number 2, you can compare these numbers like „if orderstatus > 4“ or other things. Like that your are more flexible, if you need to. If you don’t need to, I don’t know any disadvantages ^^
@B33fb0n3 The downside I currently think about is, that you can’t compare strings in a linked list. So when you have your order status in numbers and you have a number 2, you can compare these numbers like „if orderstatus > 4“ or other things. Like that your are more flexible, if you need to. If you don’t need to, I don’t know any disadvantages ^^
Holland LopOP
is it considered like a best practice to do so? or it is just basically preference, aside from the linked list you've mentioned previously
@Holland Lop is it considered like a best practice to do so? or it is just basically preference, aside from the linked list you've mentioned previously
It more depends on the project, that you want to build. If you need comparements like that in your project, you should use that, if you don't need them, you can still use it and then it's more a personal think what you prefer
@B33fb0n3 It more depends on the project, that you want to build. If you need comparements like that in your project, you should use that, if you don't need them, you can still use it and then it's more a personal think what you prefer
Holland LopOP
if i will be using the integer, is there any good docs that you'd suggest to read on good practice to number the statuses? for example, should i use 1, 2, 3 or 100, 200, 300, and -1 or 99 for canceled or something like that?
when I would be you, I would use create the numbers depending on my order flow. If I just do drop shipping, then I have less steps, then I would do a ecommerce. So ask yourself how many steps you have and what would be the senseful numbers?
@Holland Lop any update?
@B33fb0n3 <@406481578122936340> any update?
Holland LopOP
Apparently mysql support enum. I decided to use enum, as i still don't have a usecase for the linkedlist comparison for now. Thank you for your help!
@Holland Lop Apparently mysql support enum. I decided to use enum, as i still don't have a usecase for the linkedlist comparison for now. Thank you for your help!
Great to hear, that you found a a way. Just to solved this post with this message:
Currently you don't need to use linkedlist via numbers in your orders. you decided to use enums instead, to keep track of the order fulfillment
Please mark solution
Currently you don't need to use linkedlist via numbers in your orders. you decided to use enums instead, to keep track of the order fulfillment
Please mark solution
Answer