#What is the most ideal way to create arrays in tables?

4 messages · Page 1 of 1 (latest)

fleet gull
#

What is the most ideal way to create a column of type array, Should I use the JSON datatype or table relationships?
And if I want to make a like system, would it be like:

$table->json("likes")->default("[]");

and have that JSON array have the IDs of the users who liked, and the length of that array be the like count.
Or make a separate table called likes that is like:

$table->bigInteger("post_id")->unsigned();
$table->bigInteger("user_id")->unsigned();
twin ridge
#

This is a "How should I build my app?" question which is up to you to figure out. Based on this and your other question it seems like you aren't an experienced developer.

Work your way through http://laravelfromscratch.com/ or a similar tutorial and you will have better questions

Laracasts

We don't learn tools for the sake of learning tools. Instead, we learn them because they help us accomplish a particular goal. With that in mind, in this series, we'll use the common desire for a blog - with categories, tags, comments, email notifications, and more - as our goal. Laravel will be the tool that helps us get there. Each lesson, ge...

#

Also read the entire documentation so you know what is possible and suggested

solar mirage