Hi guys, just wondering if anyone can point me thr...
# javascript
d
Hi guys, just wondering if anyone can point me through the right direction, I’m making a business directory where users can review a business by leaving a rating from. 1-10 I have a table with all the business names and details. How would implement a voting system for only logged in users. I was thinking adding a column with a count of votes, but don’t know how to make sure logged in users can vote once
t
how about another table that has 2 foreign keys to both user and business. This table will able to have aditional fields such as
vote_date
you will be able to get some analytics. You will be able to create a postgres view that will be able to return the business with a subquery that includes the count of votes.
d
Hey, thank you for helping 🙏🏽
I will give that a go
So create a third table for users data? Or the original one is enough
I’m not looking for any profile customization
Just track logged in users for now
So three tables 1- business details that has a business_id 2- business ratings table that has a column foreign to business Id from first table and user Id foreign from users table 3- users table
t
I'll find specifics though the users table comes built in.
You'll need for foreign key reference
auth.users
for authenticated users.
Copy code
sql
  user_id uuid references auth.users not null,
So you won't need a separate
users
table.
d
Alright got it
Thank you
Will give it a go
t
no worries