How would I implement a star rating system into my Database design?

Viewed 8084

I am currently making an Android app where I want to allow users to rate posts, posted by other users.

ERD model of Database

This is my current design, however, would I include Rating as a separate table or included in the Media upload table?

If it is a separate table would it be something like this?

Rating table: (Rating, PostID, Rating_Count, Average_Rating)

If anything else looks wrong with my design that would also be appreciated!

3 Answers

you can use stretcher like this

enter code here
        $table->bigIncrements('id');
        $table->bigInteger('user_id')->unsigned();
        $table->ipAddress('ip')->nullable();
        $table->integer('star');
        $table->string('type');           
        $table->string('title');
        $table->string('average')->nullable()->default(0);
        $table->integer('count_star')->default(0)->nullable();
        $table->float('star_avg')->default(0)->nullable();
        $table->float('unstar_avg')->default(0)->nullable();
Related