what data type should i use for storing inventory in mysql? I json_encode and decode varchar(255)? or longtext? or what?
How are you encoding the inventory contents? They can be stored as a BLOB (or maybe a lengthy VARBINARY) if you serialize them using BigEndianNBTStream.
Sorry, I skipped over the part where you said you json encode them. You could directly go with the JSON data type if you're on MySQL 8.0 or else TEXT would do.
Yeah. Actually, since you're json_encoding them, go with LONGTEXT as the encoded data is definitely much longer in comparison to items encoded in binary using the BigEndianNBTStream
P.S. If you'd like to save on storage space, you can nbt encode them like I've done with PlayerVaults: https://github.com/Muqsit/PlayerVau...sit/playervaults/database/Vault.php#L87-#L108 Drawbacks: output is not human readable
You shouldn't use JSON at all. Store the items of an inventory in separate rows. Only use JSON when you cannot determine the types present.