Mapping a Mongodb ObjectId for a Mysql Identifier Field

I have a mongodb based application that uses 12 objectid bytes as primary key and as user id and I have another Django application using Mysql and you need to inherit the user id generated from mongodb (inherit means not create a new id , but just store the identifier that comes from mongodb, and use it as a foreign key anywhere).

What is the best solution

  • What data type will be used to express the id of the Mongo object in mysql? binary (12)? lithium>
  • considering using Django, any additional plugin needed to use binary code (12)?
  • or any other solution other than the above?

Thanks.

+4
source share
1 answer

I use BINARY(12) and VARCHAR(24) to store MongoDB ObjectIds in MySQL. BINARY(12) uses less disk space, but you need to use HEX() to work with it as a string.

+5
source

All Articles