Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Shuvoo's avatar

Database relationship with json id to others table ID

Database stracture

{ 
   "_id":"5dcac18f35630000ee0058e7",
   "campaign_id":"5dc9a4ad35630000ee0058e0",
   "pid":[ 
      "5dc859ab35630000ee0058db"
   ],
   "network_id":"5dc84ccb35630000ee0058d7",
   "coverage":[ 
      "AX"
   ],
  
   "updated_at":"2019-11-12T14:28:31.000Z",
   "created_at":"2019-11-12T14:28:31.000Z"
}

Other table

{ 
   "_id":"5dc859ab35630000ee0058db",
   "network_id":"5dc84ccb35630000ee0058d7",
   "sid":"1",
   "email":"[email protected]",
   "status":"active",
   "updated_at":"2019-11-10T18:40:43.000Z",
   "created_at":"2019-11-10T18:40:43.000Z"
}

relation make between

"pid":[ 
      "5dc859ab35630000ee0058db"
   ],
to 
2nd table
 "_id":"5dc859ab35630000ee0058db",
0 likes
3 replies
jlrdw's avatar

Are you showing this, or is there a question.

Tray2's avatar

Doesn't people understand how the database is working?

It's allowed to have more than one column in a table. The limit for MySQL is 4K or somesuch.

It's almost never a good idea to store json in the database. If it's possible to avoid using clobs (character large objects) do that since they might make your database a bit slower if they are big and you do a lot of inserts and deletes.

Please or to participate in this conversation.