{"id":433,"date":"2026-11-22T17:00:00","date_gmt":"2026-11-22T12:00:00","guid":{"rendered":"https:\/\/www.shaz3e.com\/blog\/?p=433"},"modified":"2026-11-22T17:32:42","modified_gmt":"2026-11-22T12:32:42","slug":"crm-database-schema","status":"publish","type":"post","link":"https:\/\/www.shaz3e.com\/blog\/crm-database-schema\/","title":{"rendered":"Designing a CRM Database Schema in MySQL"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A <strong>crm database schema<\/strong> looks simple on a whiteboard: contacts, companies, deals. It gets harder the first time a deal ends up pointing at a stage from the wrong pipeline, a deleted contact blocks a new one with the same email, or a query returns another tenant&#8217;s rows because somebody forgot a <code>WHERE<\/code>. Most of those bugs can be stopped in the schema instead of in code review.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is the hands-on version. My <a href=\"https:\/\/www.shaz3e.com\/blog\/how-to-build-a-crm\/\">guide to building a CRM<\/a> covers the architecture and the product side. This post is about MySQL schema design in practice: the actual tables, the keys that hold them together, the indexes behind the list views, and checks that show which mistakes the database rejects. Everything below ran on <strong>MySQL 8.4.11<\/strong> (the LTS line, default <code>utf8mb4_0900_ai_ci<\/code> collation and strict SQL mode). The full files are <code>schema.sql<\/code>, <code>seed.sql<\/code>, <code>bulk.sql<\/code>, <code>queries.sql<\/code> and <code>checks.sh<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"tables\">The tables in this CRM data model<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Table<\/th><th>What it holds<\/th><\/tr><\/thead><tbody><tr><td><code>tenants<\/code><\/td><td>One row per customer account. Every other table carries <code>tenant_id<\/code>.<\/td><\/tr><tr><td><code>users<\/code>, <code>roles<\/code>, <code>role_user<\/code><\/td><td>People who log in, and what they&#8217;re allowed to do.<\/td><\/tr><tr><td><code>companies<\/code>, <code>contacts<\/code><\/td><td>Who you sell to. Contacts can belong to a company, or not.<\/td><\/tr><tr><td><code>pipelines<\/code>, <code>stages<\/code>, <code>deals<\/code><\/td><td>Sales pipelines, their ordered stages, and the money moving through them.<\/td><\/tr><tr><td><code>activities<\/code><\/td><td>The timeline: notes, calls, emails, meetings on any record.<\/td><\/tr><tr><td><code>tasks<\/code><\/td><td>Things someone has to do, optionally tied to a contact or a deal.<\/td><\/tr><tr><td><code>tags<\/code>, <code>taggables<\/code><\/td><td>Free-form labels on contacts, companies and deals.<\/td><\/tr><tr><td><code>custom_fields<\/code><\/td><td>Per-tenant field definitions. Values live in a JSON column.<\/td><\/tr><tr><td><code>audit_log<\/code>, <code>deal_stage_changes<\/code><\/td><td>Who changed what, and how deals moved between stages.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Primary keys are <code>BIGINT UNSIGNED AUTO_INCREMENT<\/code>. UUIDs work too, but they make every secondary index bigger. If you need unguessable public IDs, add a separate column.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"tenant-keys\">Multi-tenant keys: make tenant_id part of every foreign key<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is the decision I&#8217;d make first. In a shared-database setup (the trade-offs are in my post on <a href=\"https:\/\/www.shaz3e.com\/blog\/multi-tenant-saas-architecture\/\">multi-tenant SaaS architecture<\/a>), every row carries <code>tenant_id<\/code>. The usual mistake is to add the column and stop there. Then <code>deals.contact_id<\/code> is a plain foreign key to <code>contacts.id<\/code>, and nothing stops a deal in tenant 1 from pointing at a contact in tenant 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The fix is a composite unique key on each parent, <code>(tenant_id, id)<\/code>, and composite foreign keys on each child. Here&#8217;s <code>deals<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE TABLE deals (\n  id           BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n  tenant_id    BIGINT UNSIGNED NOT NULL,\n  pipeline_id  BIGINT UNSIGNED NOT NULL,\n  stage_id     BIGINT UNSIGNED NOT NULL,\n  contact_id   BIGINT UNSIGNED NULL,\n  company_id   BIGINT UNSIGNED NULL,\n  owner_id     BIGINT UNSIGNED NULL,\n  title        VARCHAR(190) NOT NULL,\n  amount       DECIMAL(15,2) NOT NULL DEFAULT 0.00,\n  currency     CHAR(3) NOT NULL DEFAULT 'USD',\n  expected_close_on DATE NULL,\n  closed_at    TIMESTAMP NULL,\n  created_at   TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  updated_at   TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  deleted_at   TIMESTAMP NULL,\n  UNIQUE KEY deals_tenant_id (tenant_id, id),\n  KEY deals_board (tenant_id, pipeline_id, stage_id, deleted_at),\n  KEY deals_owner (tenant_id, owner_id, expected_close_on),\n  CONSTRAINT deals_stage_fk   FOREIGN KEY (tenant_id, pipeline_id, stage_id) REFERENCES stages (tenant_id, pipeline_id, id),\n  CONSTRAINT deals_contact_fk FOREIGN KEY (tenant_id, contact_id) REFERENCES contacts (tenant_id, id),\n  CONSTRAINT deals_company_fk FOREIGN KEY (tenant_id, company_id) REFERENCES companies (tenant_id, id),\n  CONSTRAINT deals_owner_fk   FOREIGN KEY (tenant_id, owner_id) REFERENCES users (tenant_id, id),\n  CONSTRAINT deals_amount_chk CHECK (amount &gt;= 0)\n) ENGINE=InnoDB;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Two things are going on. <code>deals_contact_fk<\/code> uses <code>(tenant_id, contact_id)<\/code>, so the contact has to exist <em>in the same tenant<\/em>. And <code>deals_stage_fk<\/code> covers three columns, so the stage has to belong to the deal&#8217;s pipeline as well as its tenant. The <code>stages<\/code> table has a matching unique key on <code>(tenant_id, pipeline_id, id)<\/code>. In the checks, a deal pointing at another tenant&#8217;s contact and a deal with a stage from a different pipeline both fail with error 1452.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From the <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.4\/en\/create-table-foreign-keys.html\" target=\"_blank\" rel=\"noopener\">MySQL foreign key docs<\/a>: if any column in a composite foreign key is NULL, the constraint isn&#8217;t checked. That&#8217;s what you want for optional links like <code>company_id<\/code>. It also means <code>tenant_id<\/code> must be <code>NOT NULL<\/code> everywhere, or the whole safety net goes away.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This doesn&#8217;t replace scoping queries by tenant in the application. MySQL has no row-level security, so your app still adds <code>WHERE tenant_id = ?<\/code> to every query (in Laravel that&#8217;s usually a global scope, as in my <a href=\"https:\/\/www.shaz3e.com\/blog\/laravel-multi-tenancy-tutorial\/\">single-database multi-tenancy tutorial<\/a>). What the keys add is that a bug in that scope can&#8217;t write cross-tenant links.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"users-roles\">Users and roles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Users get <code>UNIQUE (tenant_id, email)<\/code>, so one person can be a user in two accounts. Roles are per tenant, and <code>role_user<\/code> uses the same composite keys, so a tenant 2 role can&#8217;t be given to a tenant 1 user. Keep permissions in code (role name to allowed actions) until customers ask for custom roles, then add a <code>permissions<\/code> table.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"contacts\">Contacts, soft deletes and the unique email problem<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">CRMs soft-delete. People delete a contact by accident, and the activity history should survive. The standard <code>deleted_at<\/code> column clashes with one rule you almost always want: one live contact per email per tenant. A plain <code>UNIQUE (tenant_id, email)<\/code> blocks re-adding an email after the old contact was deleted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">MySQL lets several rows share a NULL in a unique index, so the trick is a generated column that is NULL once the row is deleted:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>active_email VARCHAR(190) AS (IF(deleted_at IS NULL, email, NULL)) VIRTUAL,\nUNIQUE KEY contacts_tenant_id (tenant_id, id),\nUNIQUE KEY contacts_tenant_active_email (tenant_id, active_email),<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The checks confirm the behavior: a second live <code>AYESHA@northwind.test<\/code> is rejected (1062; the default collation is case-insensitive, so case doesn&#8217;t help), the same email in another tenant is fine, re-adding an email after a soft delete works, and restoring the old row while a live duplicate exists fails. That last failure is correct. Your restore flow has to offer a merge. Duplicates come in from every intake path, which is why <a href=\"https:\/\/elosync.com\/blog\/2026\/10\/29\/clean-contact-data\/\" target=\"_blank\" rel=\"noopener\">keeping contact data clean<\/a> is mostly about catching them at entry.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"pipelines\">Pipelines, stages and deals<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Stages have a <code>position<\/code> (unique per pipeline) and an <code>outcome<\/code> of <code>open<\/code>, <code>won<\/code> or <code>lost<\/code>. Putting the outcome on the stage rather than the deal means a team can rename &#8220;Won&#8221; to &#8220;Signed&#8221; without breaking reports. Lead status and deal stage are different things, and EloSync&#8217;s write-up on <a href=\"https:\/\/elosync.com\/blog\/2026\/10\/30\/deal-stage-vs-lead-status\/\" target=\"_blank\" rel=\"noopener\">deal stage vs lead status<\/a> covers that from the user&#8217;s side. In this schema a lead is a contact without a deal yet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Money is <code>DECIMAL(15,2)<\/code> with a <code>CHAR(3)<\/code> currency, never <code>FLOAT<\/code>. A <code>CHECK (amount &gt;= 0)<\/code> rejects negative values, and MySQL 8.0.16+ does enforce <code>CHECK<\/code> constraints (error 3819 in the checks). The board query that feeds a <a href=\"https:\/\/www.shaz3e.com\/blog\/react-kanban-board\/\">React Kanban pipeline<\/a> groups open deals by stage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>EXPLAIN SELECT s.id AS stage_id, s.name, COUNT(d.id) AS deals, COALESCE(SUM(d.amount), 0) AS total\nFROM stages s\nLEFT JOIN deals d\n  ON d.tenant_id = s.tenant_id AND d.pipeline_id = s.pipeline_id\n AND d.stage_id = s.id AND d.deleted_at IS NULL\nWHERE s.tenant_id = 1 AND s.pipeline_id = 1\nGROUP BY s.id, s.name, s.position\nORDER BY s.position;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"activities-tasks\">Activities are polymorphic, tasks are not<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>activities<\/code> is polymorphic: <code>subject_type<\/code> plus <code>subject_id<\/code>, like Laravel&#8217;s morph relations. One table, one index for every timeline, and adding a new record type is an <code>ENUM<\/code> change. The cost is that the database can&#8217;t enforce <code>subject_id<\/code>, since a foreign key can only point at one table. Deleting a deal leaves orphan activities unless your code cleans them up, which is acceptable for an append-only timeline.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE TABLE activities (\n  id            BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n  tenant_id     BIGINT UNSIGNED NOT NULL,\n  subject_type  ENUM('contact','company','deal') NOT NULL,\n  subject_id    BIGINT UNSIGNED NOT NULL,\n  user_id       BIGINT UNSIGNED NULL,\n  kind          ENUM('note','call','email','meeting') NOT NULL,\n  body          TEXT NULL,\n  occurred_at   DATETIME NOT NULL,\n  KEY activities_timeline (tenant_id, subject_type, subject_id, occurred_at),\n  CONSTRAINT activities_tenant_fk FOREIGN KEY (tenant_id) REFERENCES tenants (id),\n  CONSTRAINT activities_user_fk   FOREIGN KEY (tenant_id, user_id) REFERENCES users (tenant_id, id)\n) ENGINE=InnoDB;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>tasks<\/code> uses an &#8220;exclusive arc&#8221; instead: one nullable foreign key per parent type and a <code>CHECK<\/code> that at most one is set. Tasks get edited, reassigned and completed, and a task pointing at a deal that doesn&#8217;t exist is a real bug, so I want the foreign keys. A task linked to both a contact and a deal fails with 3819.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CONSTRAINT tasks_one_parent  CHECK ((contact_id IS NOT NULL) + (deal_id IS NOT NULL) &lt;= 1)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Tags use the polymorphic pattern too (<code>taggables<\/code>), with a composite foreign key to <code>tags<\/code> so the tag at least belongs to the right tenant.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"custom-fields\">Custom fields: EAV vs JSON columns<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Every CRM customer wants fields you didn&#8217;t plan for. The two common designs:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th><\/th><th>EAV (a values table)<\/th><th>JSON column<\/th><\/tr><\/thead><tbody><tr><td>Shape<\/td><td><code>custom_field_values(entity_id, field_id, value_text, value_number, value_date)<\/code><\/td><td><code>contacts.custom JSON<\/code>, keys defined in <code>custom_fields<\/code><\/td><\/tr><tr><td>Reading one record<\/td><td>One join or extra query per record<\/td><td>Already on the row<\/td><\/tr><tr><td>Filtering<\/td><td>Joins per filter, typed columns are indexable<\/td><td>Functional index per field you filter on<\/td><\/tr><tr><td>Type safety<\/td><td>Typed value columns<\/td><td>Validate in the app against <code>custom_fields<\/code><\/td><\/tr><tr><td>Fits<\/td><td>Lots of fields filtered in many combinations<\/td><td>Fields mostly shown and edited, a few filtered<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I went with JSON. Most custom fields are displayed and edited, rarely filtered, and loading a contact shouldn&#8217;t need a join. For a field people do filter on, MySQL supports <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.4\/en\/create-index.html\" target=\"_blank\" rel=\"noopener\">functional key parts<\/a>. You can mix them with normal columns, so the index starts with <code>tenant_id<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>KEY contacts_lead_source (tenant_id, (CAST(custom-&gt;&gt;'$.lead_source' AS CHAR(40)) COLLATE utf8mb4_bin)),<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>COLLATE utf8mb4_bin<\/code> matters because <code>-&gt;&gt;<\/code> returns a binary-collated string. With it, a plain <code>WHERE custom-&gt;&gt;'$.lead_source' = 'referral'<\/code> used the index in my test: <code>ref<\/code> access, 100 estimated rows, which matched the 100 rows with that value. For values that cover a third of the tenant&#8217;s contacts, the optimizer chose the tenant index instead, which is reasonable. A functional index is only worth it for selective values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"indexes\">Indexes for the list views<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Design indexes from the screens, not the tables. To get real plans I loaded 50,000 contacts and 20,000 deals into tenant 1 with <code>bulk.sql<\/code> and ran <code>EXPLAIN<\/code> on each list query. (My post on <a href=\"https:\/\/www.shaz3e.com\/blog\/mysql-indexes-laravel\/\">database indexing for Laravel developers<\/a> covers composite index order in more depth.)<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Screen<\/th><th>Index<\/th><th>EXPLAIN result<\/th><\/tr><\/thead><tbody><tr><td>My contacts, newest first<\/td><td><code>(tenant_id, owner_id, deleted_at, created_at)<\/code><\/td><td><code>contacts_owner_list<\/code>, range, backward index scan, no filesort<\/td><\/tr><tr><td>Kanban board<\/td><td><code>(tenant_id, pipeline_id, stage_id, deleted_at)<\/code><\/td><td><code>deals_board<\/code> on all four columns<\/td><\/tr><tr><td>Deal timeline<\/td><td><code>(tenant_id, subject_type, subject_id, occurred_at)<\/code><\/td><td><code>activities_timeline<\/code>, backward index scan<\/td><\/tr><tr><td>Filter by lead source<\/td><td><code>(tenant_id, (lead_source expr))<\/code><\/td><td><code>contacts_lead_source<\/code>, ref<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The contacts list uses keyset pagination (<code>created_at &lt; ?<\/code>) rather than <code>OFFSET<\/code>, because a deep offset reads and discards every skipped row. The board query reported &#8220;Using temporary; Using filesort&#8221; on <code>stages<\/code>, which is four rows. That&#8217;s fine. I&#8217;m not quoting timings, because this dataset says little about production. The plans are there to confirm the right index gets picked.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"audit\">Audit log and stage history<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>audit_log<\/code> is append-only and written by the application, because only the app knows the user and the request. Store a JSON diff of changed fields, not full row copies.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Stage history is the one place I&#8217;d use a trigger, because pipeline reports (time in stage, conversion between stages) depend on it being complete, and a trigger catches updates from scripts and admin tools too:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE TRIGGER deals_stage_history AFTER UPDATE ON deals\nFOR EACH ROW\nBEGIN\n  IF NOT (NEW.stage_id &lt;=&gt; OLD.stage_id) THEN\n    INSERT INTO deal_stage_changes (tenant_id, deal_id, from_stage_id, to_stage_id, changed_by)\n    VALUES (NEW.tenant_id, NEW.id, OLD.stage_id, NEW.stage_id, @app_user_id);\n  END IF;\nEND\/\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The app sets <code>@app_user_id<\/code> on its connection before writing. The <code>&lt;=&gt;<\/code> comparison means only real stage changes are logged. In the checks, moving a deal from Qualified to Proposal wrote one row with the right user, and editing the amount wrote nothing. If you use a connection pool, reset that variable per request, or a later request can be logged under the wrong user.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"checks\">Running the checks<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>checks.sh<\/code> loads the schema and seed into a fresh database, then expects each of 16 statements to succeed or fail with a specific MySQL error code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>MYSQL=\"mysql -uroot -S \/tmp\/mysql.sock\" .\/checks.sh\n# ...\n# passed=16 failed=0<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"limits\">What I didn&#8217;t test<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>MariaDB. Its JSON type and index support differ from MySQL&#8217;s, so test there before copying this. I also didn&#8217;t run it on MySQL 8.0 or 9.x.<\/li>\n\n\n<li>Production-sized data or concurrency. The 50,000 rows were for <code>EXPLAIN<\/code>, not load testing.<\/li>\n\n\n<li>Data migrations, archiving or partitioning for large tenants.<\/li>\n\n\n<li>An application layer. Tenant scoping, permissions and custom field validation still live in your code.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"faq\">FAQ<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"faq-separate-db\">Should each tenant get its own database instead?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s a valid choice with stronger isolation and harder migrations. If you start with a shared database, the composite keys here are what keep tenants apart at the data level.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"faq-leads-table\">Do I need a separate leads table?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Not usually. A lead is a contact with no deal yet, plus a status column if your team tracks lead stages. A separate table means copying data across when the lead converts, and that&#8217;s where duplicates start.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"faq-eav\">When would EAV beat JSON for custom fields?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When users build reports that filter on many custom fields in arbitrary combinations. Typed EAV columns can be indexed generically. JSON needs one functional index per field.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;d rather use a CRM than build one, <a href=\"https:\/\/elosync.com\/\" target=\"_blank\" rel=\"noopener\">EloSync<\/a> is the CRM I build. Leads, Tasks and ToDos are free. If you&#8217;re building your own crm database schema, start with <code>tenant_id<\/code> in every foreign key. Adding it later means rewriting every foreign key on tables that already hold data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>I&#8217;m <a href=\"https:\/\/shaz3e.com\" target=\"_blank\" rel=\"noopener\">Shahrukh Akhtar (Shaz3e)<\/a>, CTO &amp; Co-Founder of Diligent Creators Pvt. Ltd., a Technology Executive &amp; Product Builder. I run client delivery and build SaaS products, including EloSync. You can find me on <a href=\"https:\/\/x.com\/shaz3e\" target=\"_blank\" rel=\"noopener\">X<\/a>, <a href=\"https:\/\/linkedin.com\/in\/shaz3e\" target=\"_blank\" rel=\"noopener\">LinkedIn<\/a>, <a href=\"https:\/\/peerlist.io\/shaz3e\" target=\"_blank\" rel=\"noopener\">Peerlist<\/a> and <a href=\"https:\/\/github.com\/Shaz3e\" target=\"_blank\" rel=\"noopener\">GitHub<\/a>.<\/em><\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>A hands-on crm database schema for MySQL 8.4: tenant-safe composite foreign keys, soft deletes with unique emails, pipelines and stages, polymorphic activities, JSON custom fields, list-view indexes and a stage-history trigger. Tested on 8.4.11.<\/p>\n","protected":false},"author":2,"featured_media":434,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[3],"tags":[124,49,126,42],"class_list":["post-433","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev","tag-building-a-crm","tag-multi-tenancy","tag-mysql","tag-saas-architecture"],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/phsTKQ-6Z","jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.shaz3e.com\/blog\/wp-content\/uploads\/2026\/11\/crm-database-schema-1200x630-1.jpg?fit=1200%2C630&ssl=1","_links":{"self":[{"href":"https:\/\/www.shaz3e.com\/blog\/wp-json\/wp\/v2\/posts\/433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shaz3e.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shaz3e.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shaz3e.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shaz3e.com\/blog\/wp-json\/wp\/v2\/comments?post=433"}],"version-history":[{"count":2,"href":"https:\/\/www.shaz3e.com\/blog\/wp-json\/wp\/v2\/posts\/433\/revisions"}],"predecessor-version":[{"id":436,"href":"https:\/\/www.shaz3e.com\/blog\/wp-json\/wp\/v2\/posts\/433\/revisions\/436"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.shaz3e.com\/blog\/wp-json\/wp\/v2\/media\/434"}],"wp:attachment":[{"href":"https:\/\/www.shaz3e.com\/blog\/wp-json\/wp\/v2\/media?parent=433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shaz3e.com\/blog\/wp-json\/wp\/v2\/categories?post=433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shaz3e.com\/blog\/wp-json\/wp\/v2\/tags?post=433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}