title: How to structure my database so that only logged in user can add, delete, or edit only their posts?
body: <p>I am using Express.js to make a Web App and am learning authentication using passportjs. I basically have a crud web app that lets me edit, delete or add anything from my web app by anybody. Here is what my Postgres database looks like.</p>
  
  <pre><code>  \connect usertesterdb;
  
    CREATE TABLE IF NOT EXISTS users (
     id BIGSERIAL PRIMARY KEY,
     username VARCHAR(255),
     email VARCHAR(255),
     password TEXT UNIQUE NOT NULL
    );
  </code></pre>
  
  <p>And</p>
  
  <pre><code>  CREATE TABLE IF NOT EXISTS mymenutable (
     id BIGSERIAL PRIMARY KEY,
     foodtitle VARCHAR(255),
     fooddescription TEXT,
    );
  </code></pre>
  
  <p>What would be the best possible way so that I can achieve my goal? At the moment, the two tables are not communicating with each other. I would appreciate some strategies or good practices that would make the code clean and maintainable.</p>
  
  <p>EDIT: I am thinking I could add another column in my "mymenutable" called "userid" which references the id number of the user from "users" table and then every time the user creates or edit or delete their posts or menus, it checks whether the logged in user's id is equal to the menu's "userid". I don't know if this would be the right way to do it or if it can be manipulated somehow.</p>