Schema Library

Popular database schema diagrams

Explore the real database schemas behind popular projects. Every diagram shows tables, columns, primary keys, and foreign key relationships, rendered from official migrations and docs.

* 1 * 1 * 1 users instance_id uuid id uuid PK aud varchar(255) role varchar(255) email varchar(255) encrypted_password varchar(255) email_confirmed_at timestamptz invited_at timestamptz confirmation_token varchar(255) confirmation_sent_at timestamptz recovery_token varchar(255) recovery_sent_at timestamptz email_change_token_new varchar(255) email_change varchar(255) email_change_sent_at timestamptz last_sign_in_at timestamptz raw_app_meta_data jsonb raw_user_meta_data jsonb is_super_admin bool created_at timestamptz updated_at timestamptz phone text phone_confirmed_at timestamptz phone_change text phone_change_token varchar(255) phone_change_sent_at timestamptz confirmed_at timestamptz email_change_token_current varchar(255) email_change_confirm_status smallint banned_until timestamptz reauthentication_token varchar(255) reauthentication_sent_at timestamptz is_sso_user bool deleted_at timestamptz is_anonymous bool identities provider_id text user_id uuid FK identity_data jsonb provider text last_sign_in_at timestamptz created_at timestamptz updated_at timestamptz email text id uuid PK sessions id uuid PK user_id uuid FK created_at timestamptz updated_at timestamptz factor_id uuid aal aal_level not_after timestamptz refreshed_at timestamp user_agent text ip inet tag text oauth_client_id uuid refresh_token_hmac_key text refresh_token_counter bigint scopes text refresh_tokens instance_id uuid id bigint PK token varchar(255) user_id varchar(255) revoked bool created_at timestamptz updated_at timestamptz parent varchar(255) session_id uuid FK instances id uuid PK uuid uuid raw_base_config text created_at timestamptz updated_at timestamptz audit_log_entries instance_id uuid id uuid PK payload json created_at timestamptz ip_address varchar(64) schema_migrations version varchar(255) PK Made with dbdiagramr

Supabase

Supabase Auth Schema Diagram: Users, Identities, Sessions

7 tablesView diagram
* 1 * 1 users id int PK name varchar(255) email varchar(255) emailVerified timestamptz image text accounts id int PK userId int FK type varchar(255) provider varchar(255) providerAccountId varchar(255) refresh_token text access_token text expires_at bigint id_token text scope text session_state text token_type text sessions id int PK userId int FK expires timestamptz sessionToken varchar(255) verification_token identifier text PK token text PK expires timestamptz Made with dbdiagramr

NextAuth.js

NextAuth.js Database Schema (Auth.js)

4 tablesView diagram
users id bigint PK name varchar email varchar email_verified_at timestamp password varchar remember_token varchar(100) created_at timestamp updated_at timestamp password_reset_tokens email varchar PK token varchar created_at timestamp sessions id varchar PK user_id bigint ip_address varchar(45) user_agent text payload text last_activity int jobs id bigint PK queue varchar payload text attempts smallint reserved_at int available_at int created_at int job_batches id varchar PK name varchar total_jobs int pending_jobs int failed_jobs int failed_job_ids text options text cancelled_at int created_at int finished_at int failed_jobs id bigint PK uuid varchar connection varchar queue varchar payload text exception text failed_at timestamp cache key varchar PK value text expiration bigint cache_locks key varchar PK owner varchar expiration bigint Made with dbdiagramr

Laravel

Laravel Database Schema Diagram

8 tablesView diagram
* 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 auth_user id integer GENERATED BY DEFAULT AS IDENTITY PK password varchar(128) last_login timestamptz is_superuser boolean username varchar(150) first_name varchar(150) last_name varchar(150) email varchar(254) is_staff boolean is_active boolean date_joined timestamptz auth_group id integer GENERATED BY DEFAULT AS IDENTITY PK name varchar(150) auth_permission id integer GENERATED BY DEFAULT AS IDENTITY PK name varchar(255) content_type_id int FK codename varchar(100) auth_user_groups id integer GENERATED BY DEFAULT AS IDENTITY PK user_id int FK group_id int FK auth_user_user_permissions id integer GENERATED BY DEFAULT AS IDENTITY PK user_id int FK permission_id int FK auth_group_permissions id integer GENERATED BY DEFAULT AS IDENTITY PK group_id int FK permission_id int FK django_content_type id integer GENERATED BY DEFAULT AS IDENTITY PK app_label varchar(100) model varchar(100) django_admin_log id integer GENERATED BY DEFAULT AS IDENTITY PK action_time timestamptz object_id text object_repr varchar(200) action_flag smallint change_message text content_type_id int FK user_id int FK django_session session_key varchar(40) PK session_data text expire_date timestamptz Made with dbdiagramr

Django

Django Auth Database Schema Diagram

9 tablesView diagram
* 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 customers id text PK email varchar name varchar phone varchar description text currency varchar(3) balance int metadata jsonb created timestamptz deleted_at timestamptz products id text PK name varchar description text active bool type varchar metadata jsonb created timestamptz updated timestamptz prices id text PK product_id text FK unit_amount int currency varchar(3) recurring_interval varchar recurring_interval_count int active bool type varchar created timestamptz subscriptions id text PK customer_id text FK status varchar collection_method varchar current_period_start timestamptz current_period_end timestamptz cancel_at_period_end bool canceled_at timestamptz trial_start timestamptz trial_end timestamptz default_payment_method_id text FK metadata jsonb created timestamptz subscription_items id text PK subscription_id text FK price_id text FK quantity int created timestamptz invoices id text PK customer_id text FK subscription_id text FK status varchar amount_due int amount_paid int currency varchar(3) attempt_count int due_date timestamptz paid_at timestamptz hosted_invoice_url text created timestamptz invoice_line_items id text PK invoice_id text FK price_id text FK amount int currency varchar(3) description text quantity int period_start timestamptz period_end timestamptz payment_methods id text PK customer_id text FK type varchar card_brand varchar card_last4 varchar(4) card_exp_month smallint card_exp_year smallint billing_country varchar(2) created timestamptz payment_intents id text PK customer_id text FK invoice_id text FK amount int currency varchar(3) status varchar payment_method_id text FK client_secret text created timestamptz Made with dbdiagramr

Stripe

Stripe Billing Database Schema Diagram

9 tablesView diagram
* 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 customers id uuid PK email varchar first_name varchar last_name varchar phone varchar created_at timestamptz updated_at timestamptz addresses id uuid PK customer_id uuid FK label varchar line1 varchar line2 varchar city varchar state varchar postal_code varchar country varchar(2) is_default bool categories id uuid PK name varchar slug varchar parent_id uuid FK description text created_at timestamptz products id uuid PK title varchar slug varchar description text category_id uuid FK price_cents int currency varchar(3) inventory_count int is_active bool created_at timestamptz updated_at timestamptz product_images id uuid PK product_id uuid FK url text alt_text varchar position int created_at timestamptz carts id uuid PK customer_id uuid FK status varchar created_at timestamptz updated_at timestamptz expires_at timestamptz cart_items id uuid PK cart_id uuid FK product_id uuid FK quantity int unit_price_cents int added_at timestamptz orders id uuid PK customer_id uuid FK status varchar total_cents int currency varchar(3) shipping_address_id uuid FK billing_address_id uuid FK placed_at timestamptz paid_at timestamptz shipped_at timestamptz order_items id uuid PK order_id uuid FK product_id uuid FK product_title varchar quantity int unit_price_cents int total_cents int created_at timestamptz payments id uuid PK order_id uuid FK provider varchar provider_payment_id text amount_cents int currency varchar(3) status varchar created_at timestamptz reviews id uuid PK product_id uuid FK customer_id uuid FK rating smallint title varchar body text created_at timestamptz Made with dbdiagramr

E-commerce

E-commerce Database Schema Diagram (PostgreSQL)

11 tablesView diagram
* 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 publishers id uuid PK name varchar city varchar country varchar authors id uuid PK first_name varchar last_name varchar birth_year int books isbn varchar(13) PK title varchar publisher_id uuid FK published_year int edition int category varchar price numeric(10,2) book_authors isbn varchar(13) PK author_id uuid PK copies id uuid PK isbn varchar(13) FK barcode varchar shelf varchar status varchar members id uuid PK first_name varchar last_name varchar email varchar phone varchar address text joined_at timestamptz librarians id uuid PK first_name varchar last_name varchar login_id varchar hired_at timestamptz loans id uuid PK copy_id uuid FK member_id uuid FK issued_by uuid FK issued_at timestamptz due_at timestamptz returned_at timestamptz reservations id uuid PK isbn varchar(13) FK member_id uuid FK reserved_at timestamptz fulfilled_at timestamptz fines id uuid PK loan_id uuid FK amount numeric(10,2) paid_at timestamptz Made with dbdiagramr

Library Management System

Library Management System ER Diagram (PostgreSQL)

10 tablesView diagram
* 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 departments id uuid PK name varchar building varchar floor int patients id uuid PK first_name varchar last_name varchar date_of_birth date gender varchar blood_group varchar(3) phone varchar email varchar address text emergency_contact varchar created_at timestamptz staff id uuid PK first_name varchar last_name varchar role varchar department_id uuid FK specialization varchar phone varchar hire_date date rooms id uuid PK number varchar room_type varchar capacity int beds id uuid PK room_id uuid FK bed_number varchar status varchar appointments id uuid PK patient_id uuid FK doctor_id uuid FK department_id uuid FK appointment_at timestamptz status varchar notes text medical_records id uuid PK patient_id uuid FK doctor_id uuid FK appointment_id uuid FK recorded_at timestamptz diagnosis text symptoms text treatment_plan text medications id uuid PK name varchar unit varchar price numeric(10,2) prescriptions id uuid PK record_id uuid FK medication_id uuid FK dosage varchar frequency varchar duration_days int admissions id uuid PK patient_id uuid FK bed_id uuid FK admitted_at timestamptz discharged_at timestamptz admission_type varchar bills id uuid PK patient_id uuid FK admission_id uuid FK appointment_id uuid FK total_amount numeric(10,2) insurance_covered numeric(10,2) status varchar billed_at timestamptz payments id uuid PK bill_id uuid FK amount numeric(10,2) method varchar paid_at timestamptz Made with dbdiagramr

Hospital Management System

Hospital Management System Database Schema (PostgreSQL)

12 tablesView diagram
* 1 * 1 * 1 * 1 * 1 * 1 * 1 organizations id uuid PK name varchar slug varchar created_at timestamptz users id uuid PK email varchar name varchar created_at timestamptz memberships id uuid PK organization_id uuid FK user_id uuid FK joined_at timestamptz roles id uuid PK organization_id uuid FK name varchar description text permissions id uuid PK resource varchar action varchar description text membership_roles membership_id uuid PK role_id uuid PK granted_at timestamptz role_permissions role_id uuid PK permission_id uuid PK Made with dbdiagramr

RBAC

RBAC Database Schema: Roles, Permissions & Joins

7 tablesView diagram
* 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 tenants id uuid PK name varchar slug varchar plan varchar created_at timestamptz users id uuid PK email varchar name varchar created_at timestamptz tenant_users tenant_id uuid PK user_id uuid PK role varchar joined_at timestamptz projects tenant_id uuid FK id uuid PK name varchar status varchar created_by uuid FK created_at timestamptz tasks tenant_id uuid FK id uuid PK project_id uuid FK title varchar status varchar assignee_id uuid FK due_at timestamptz created_at timestamptz invitations tenant_id uuid FK id uuid PK email varchar role varchar token varchar expires_at timestamptz accepted_at timestamptz api_keys tenant_id uuid FK id uuid PK name varchar key_hash varchar key_prefix varchar revoked_at timestamptz created_at timestamptz events tenant_id uuid FK id uuid PK actor_id uuid FK action varchar entity varchar entity_id uuid metadata jsonb created_at timestamptz Made with dbdiagramr

Multi-Tenant SaaS

Multi-Tenant SaaS Database Schema (PostgreSQL)

8 tablesView diagram
* 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 album album_id INT PK title VARCHAR(160) artist_id INT FK artist artist_id INT PK name VARCHAR(120) customer customer_id INT PK first_name VARCHAR(40) last_name VARCHAR(20) company VARCHAR(80) address VARCHAR(70) city VARCHAR(40) state VARCHAR(40) country VARCHAR(40) postal_code VARCHAR(10) phone VARCHAR(24) fax VARCHAR(24) email VARCHAR(60) support_rep_id INT FK employee employee_id INT PK last_name VARCHAR(20) first_name VARCHAR(20) title VARCHAR(30) reports_to INT FK birth_date TIMESTAMP hire_date TIMESTAMP address VARCHAR(70) city VARCHAR(40) state VARCHAR(40) country VARCHAR(40) postal_code VARCHAR(10) phone VARCHAR(24) fax VARCHAR(24) email VARCHAR(60) genre genre_id INT PK name VARCHAR(120) invoice invoice_id INT PK customer_id INT FK invoice_date TIMESTAMP billing_address VARCHAR(70) billing_city VARCHAR(40) billing_state VARCHAR(40) billing_country VARCHAR(40) billing_postal_code VARCHAR(10) total NUMERIC(10,2) invoice_line invoice_line_id INT PK invoice_id INT FK track_id INT FK unit_price NUMERIC(10,2) quantity INT media_type media_type_id INT PK name VARCHAR(120) playlist playlist_id INT PK name VARCHAR(120) playlist_track playlist_id INT PK track_id INT PK track track_id INT PK name VARCHAR(200) album_id INT FK media_type_id INT FK genre_id INT FK composer VARCHAR(220) milliseconds INT bytes INT unit_price NUMERIC(10,2) Made with dbdiagramr

Chinook

Chinook Database Schema Diagram (PostgreSQL)

11 tablesView diagram
* 1 * 1 * 1 * 1 * 1 batch_job_instance job_instance_id BIGINT PK version BIGINT job_name VARCHAR(100) job_key VARCHAR(32) batch_job_execution job_execution_id BIGINT PK version BIGINT job_instance_id BIGINT FK create_time TIMESTAMP start_time TIMESTAMP end_time TIMESTAMP status VARCHAR(10) exit_code VARCHAR(2500) exit_message VARCHAR(2500) last_updated TIMESTAMP batch_job_execution_params job_execution_id BIGINT FK parameter_name VARCHAR(100) parameter_type VARCHAR(100) parameter_value VARCHAR(2500) identifying CHAR(1) batch_step_execution step_execution_id BIGINT PK version BIGINT step_name VARCHAR(100) job_execution_id BIGINT FK create_time TIMESTAMP start_time TIMESTAMP end_time TIMESTAMP status VARCHAR(10) commit_count BIGINT read_count BIGINT filter_count BIGINT write_count BIGINT read_skip_count BIGINT write_skip_count BIGINT process_skip_count BIGINT rollback_count BIGINT exit_code VARCHAR(2500) exit_message VARCHAR(2500) last_updated TIMESTAMP batch_step_execution_context step_execution_id BIGINT PK short_context VARCHAR(2500) serialized_context TEXT batch_job_execution_context job_execution_id BIGINT PK short_context VARCHAR(2500) serialized_context TEXT Made with dbdiagramr

Spring Batch

Spring Batch Metadata Tables Diagram (PostgreSQL)

6 tablesView diagram
* 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 customer customer_id int PK store_id int FK first_name text last_name text email text address_id int FK activebool boolean create_date date last_update timestamptz active int uuid uuid actor actor_id int PK first_name text last_name text last_update timestamptz category category_id int PK name text last_update timestamptz film film_id int PK title text description text release_year public.year language_id int FK original_language_id int FK rental_duration smallint rental_rate numeric(4,2) length smallint replacement_cost numeric(5,2) rating public.mpaa_rating last_update timestamptz special_features text[] fulltext tsvector length_hours numeric(4,2) GENERATED ALWAYS AS (round(length / 60.0, 2)) STORED film_actor actor_id int PK film_id int PK last_update timestamptz film_category film_id int PK category_id int PK last_update timestamptz film_embedding film_id int PK embedding public.vector(20) last_update timestamptz address address_id int PK address text address2 text district text city_id int FK postal_code text phone text last_update timestamptz city city_id int PK city text country_id int FK last_update timestamptz country country_id int PK country text last_update timestamptz inventory inventory_id int PK film_id int FK store_id int FK last_update timestamptz language language_id int PK name text last_update timestamptz payment payment_id int PK customer_id int FK staff_id int FK rental_id int FK amount numeric(5,2) payment_date timestamptz PK uuid uuid rental rental_id int PK rental_date timestamptz inventory_id int FK customer_id int FK return_date timestamptz staff_id int FK last_update timestamptz uuid uuid staff staff_id int PK first_name text last_name text address_id int FK email text store_id int FK active boolean username text password text last_update timestamptz picture bytea store store_id int PK manager_staff_id int address_id int FK last_update timestamptz Made with dbdiagramr

Pagila

Pagila Database Schema Diagram (PostgreSQL)

16 tablesView diagram
* 1 * 1 user id text PK name text email text emailVerified boolean image text createdAt timestamptz updatedAt timestamptz session id text PK userId text FK token text expiresAt timestamptz ipAddress text userAgent text createdAt timestamptz updatedAt timestamptz account id text PK userId text FK accountId text providerId text accessToken text refreshToken text accessTokenExpiresAt timestamptz refreshTokenExpiresAt timestamptz scope text idToken text password text createdAt timestamptz updatedAt timestamptz verification id text PK identifier text value text expiresAt timestamptz createdAt timestamptz updatedAt timestamptz Made with dbdiagramr

Better Auth

Better Auth Database Schema Diagram (PostgreSQL)

4 tablesView diagram
* 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 customer customer_id int PK store_id smallint FK first_name varchar(45) last_name varchar(45) email varchar(50) address_id smallint FK activebool boolean create_date date last_update timestamp active int actor actor_id int PK first_name varchar(45) last_name varchar(45) last_update timestamp category category_id int PK name varchar(25) last_update timestamp film film_id int PK title varchar(255) description text release_year public.year language_id smallint FK rental_duration smallint rental_rate numeric(4,2) length smallint replacement_cost numeric(5,2) rating public.mpaa_rating last_update timestamp special_features text[] fulltext tsvector film_actor actor_id smallint PK film_id smallint PK last_update timestamp film_category film_id smallint PK category_id smallint PK last_update timestamp address address_id int PK address varchar(50) address2 varchar(50) district varchar(20) city_id smallint FK postal_code varchar(10) phone varchar(20) last_update timestamp city city_id int PK city varchar(50) country_id smallint FK last_update timestamp country country_id int PK country varchar(50) last_update timestamp inventory inventory_id int PK film_id smallint FK store_id smallint FK last_update timestamp language language_id int PK name char(20) last_update timestamp payment payment_id int PK customer_id smallint FK staff_id smallint FK rental_id int FK amount numeric(5,2) payment_date timestamp rental rental_id int PK rental_date timestamp inventory_id int FK customer_id smallint FK return_date timestamp staff_id smallint FK last_update timestamp staff staff_id int PK first_name varchar(45) last_name varchar(45) address_id smallint FK email varchar(50) store_id smallint FK active boolean username varchar(16) password varchar(40) last_update timestamp picture bytea store store_id int PK manager_staff_id smallint FK address_id smallint FK last_update timestamp Made with dbdiagramr

DVD Rental

DVD Rental Database ER Diagram (PostgreSQL)

15 tablesView diagram
* 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 categories category_id smallint PK category_name varchar(15) description text picture bytea customer_customer_demo customer_id varchar(5) PK customer_type_id varchar(5) PK customer_demographics customer_type_id varchar(5) PK customer_desc text customers customer_id varchar(5) PK company_name varchar(40) contact_name varchar(30) contact_title varchar(30) address varchar(60) city varchar(15) region varchar(15) postal_code varchar(10) country varchar(15) phone varchar(24) fax varchar(24) employees employee_id smallint PK last_name varchar(20) first_name varchar(10) title varchar(30) title_of_courtesy varchar(25) birth_date date hire_date date address varchar(60) city varchar(15) region varchar(15) postal_code varchar(10) country varchar(15) home_phone varchar(24) extension varchar(4) photo bytea notes text reports_to smallint FK photo_path varchar(255) employee_territories employee_id smallint PK territory_id varchar(20) PK order_details order_id smallint PK product_id smallint PK unit_price real quantity smallint discount real orders order_id smallint PK customer_id varchar(5) FK employee_id smallint FK order_date date required_date date shipped_date date ship_via smallint FK freight real ship_name varchar(40) ship_address varchar(60) ship_city varchar(15) ship_region varchar(15) ship_postal_code varchar(10) ship_country varchar(15) products product_id smallint PK product_name varchar(40) supplier_id smallint FK category_id smallint FK quantity_per_unit varchar(20) unit_price real units_in_stock smallint units_on_order smallint reorder_level smallint discontinued int region region_id smallint PK region_description varchar(60) shippers shipper_id smallint PK company_name varchar(40) phone varchar(24) suppliers supplier_id smallint PK company_name varchar(40) contact_name varchar(30) contact_title varchar(30) address varchar(60) city varchar(15) region varchar(15) postal_code varchar(10) country varchar(15) phone varchar(24) fax varchar(24) homepage text territories territory_id varchar(20) PK territory_description varchar(60) region_id smallint FK us_states state_id smallint PK state_name varchar(100) state_abbr varchar(2) state_region varchar(50) Made with dbdiagramr

Northwind

Northwind Database Diagram (PostgreSQL)

14 tablesView diagram