‹ All templates
DEVELOPMENT TEMPLATE

User authentication

Model users, sessions, roles, and permissions with a clear separation of concerns.

5 tables4 relationships4 SQL dialects
Use this template

A practical foundation, ready to adapt

This template models the core entities of a user authentication system. It gives each entity an integer primary key and connects related records with explicit foreign keys. Open it in the designer to adjust names, add fields, and choose the rules that fit your application.

What’s included

users

id (integer), email (varchar), password_hash (text), created_at (timestamp).

sessions

id (integer), user_id (integer), token_hash (varchar), expires_at (timestamp).

roles

id (integer), name (varchar).

user_roles

id (integer), user_id (integer), role_id (integer).

permissions

id (integer), role_id (integer), resource (varchar), action (varchar).

Before you build

Review nullability, uniqueness, indexes, and deletion rules for your use case. This is a starting schema, not a complete application. It does not include application logic, authorization, or migrations. Monetary fields use decimal values; timestamps and authentication fields still need appropriate handling in your application.

Keep a JSON backup as you customize the project. Then select your SQL dialect, resolve any validation issues, and review the generated statements before running them.

Learn how relationships work or explore primary keys and constraints.