Hacker News new | past | comments | ask | show | jobs | submit login

yolo hack - this way we only update 1 row, but when obtaining items, then we have to join/load entry from this table too

ItemsOrderConfiguration Table

Id | Json (varchar(MAX) or proper JSON type in Relational DBs)

1 | [

     { 
     
      "ItemId": 1, 
      
      "Order": 2
      
     },
     
     { 
     
      "ItemId": 2, 
      
      "Order": 1
      
     },
     
    ]

2 | [

     { 
     
      "ItemId": 15, 
      
      "Order": 1
      
     },
     
     { 
     
      "ItemId": 32, 
      
      "Order": 2
      
     },
     
    ]
the bad thing about this is that you lose constrains e.g that ItemId actually exists, but it shouldn't be a problem.



Postgres has an array type, so you can just make an array of IDs.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: