Home / Clayi CodeData / Data / Mock Users & Financial Transactions Database SQL Seed Dump

Mock Users & Financial Transactions Database SQL Seed Dump

Mock Users & Financial Transactions Database SQL Seed Dump
  • Category Data
  • Type SQL
  • Platform Linux, Windows, macOS, Unix
  • Language SQL
  • Price Free
  • Views 1 258
  • Comments 0
View Resource
Mock Users & Financial Transactions Database SQL Seed Dump

The Essential Role of SQL Seed Data in Software Testing

When developing a new backend application, testing API endpoints with a completely empty database is incredibly difficult and often highly inaccurate. To verify that pagination, sorting, and complex SQL joins actually work, developers need realistic data. The "Mock Users & Financial Transactions Database SQL Seed Dump" provides an instant, production-like environment. By using this professionally structured dummy data, engineering teams can rigorously test their application logic, catch edge-case bugs early, and confidently design beautiful frontend user interfaces without relying on raw, manual data entry.

Ensuring a Clean Slate with the Drop Table Strategy

Before any new tables are created or data is inserted, the script executes two critical commands: DROP TABLE IF EXISTS `transactions`; and DROP TABLE IF EXISTS `users`;. This is a standard best practice for seed files. If you run the seed script multiple times during development, failing to drop the existing tables will result in massive duplicate data errors and primary key collisions. By dropping the tables first, the script guarantees that your database is wiped completely clean and rebuilt from absolute scratch every single time you execute it.

Designing a Robust Users Table with UUIDs and Roles

The users table schema is meticulously designed to mirror modern enterprise applications. While it utilizes a standard auto-incrementing integer for the primary id (which is incredibly fast for internal database joins), it also generates a strictly unique uuid (Universally Unique Identifier) column. Exposing internal integer IDs to the public internet is a major security risk; developers should always use the UUID when routing public API requests. Furthermore, the inclusion of role and status columns provides the perfect foundation for testing complex user authorization and authentication middlewares.

Understanding the Power of the InnoDB Storage Engine

At the end of both table creation statements, you will notice the declaration ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;. InnoDB is the default and absolute most powerful storage engine available in MySQL. Unlike older engines, InnoDB fully supports ACID-compliant database transactions and row-level locking, which are mandatory features for handling sensitive financial data safely. Additionally, setting the character set to utf8mb4 ensures that your database can seamlessly store and render 100% of all international characters, including modern emojis, without crashing or corrupting the text.

Building the Financial Transactions Table Architecture

The transactions table acts as the perfect companion to the user data, simulating an e-commerce or SaaS billing environment. It includes essential columns like amount (stored accurately as a Decimal to prevent floating-point math errors), currency, and payment_method. The status column is intentionally populated with a diverse mix of states—completed, pending, and refunded. This intentional variety forces frontend developers to build dynamic UI components that change color or layout based on the exact status of the financial transaction.

Enforcing Referential Integrity with Foreign Key Constraints

The most important line in the entire script is FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE. This rule establishes a strict relational bridge between the two tables. It guarantees that a transaction cannot be assigned to a non-existent user. More importantly, the ON DELETE CASCADE directive ensures that if a user deletes their account (removing their row from the users table), the database engine will automatically and instantly wipe out all of their associated financial transactions, keeping your database perfectly clean and free of orphaned records.

Simulating Real-World Scenarios with Diverse Mock Data

The provided INSERT INTO blocks are deliberately crafted to simulate a real-world production environment. The dummy data is not uniform; it includes users with different administrative privileges (admin, developer, user) and various account standings (active, pending, suspended). The financial data spans different payment gateways (Stripe, PayPal, Apple Pay) and different fiat currencies. This rich, multi-layered dataset is absolutely crucial for writing complex, nested SQL LEFT JOIN queries and ensuring your backend analytics dashboards calculate revenue metrics accurately across diverse cohorts.

Download the Free SQL Dump File for Instant Prototyping

Manually typing out mock names, generating secure UUIDs, and calculating fake transaction amounts is a massive waste of valuable engineering time. To streamline your development workflow, you can instantly download this complete "Mock Users & Financial Transactions SQL Seed Dump" directly from this page. By importing this lightweight, highly optimized file into your local MySQL or PostgreSQL environment, you can bypass the tedious data-entry phase entirely and immediately begin writing, testing, and perfecting your core application architecture.

Popularity
0%
  • Votes: 9
  • Comments: 0

Help

Can't download assets? How to use Clayi Assets Assets not working? Can't copy? How to use Clayi Code Snippet not working?

Free Mock Users & Financial Transactions Database SQL Seed Dump SQL Download

-- ===============================================================================
-- Clayi Assets - Mock Users & Transactions SQL Seed Dump
-- Format: MySQL / PostgreSQL Compatible SQL
-- Purpose: Seed database for testing API endpoints, pagination, and SQL queries
-- License: MIT License
-- ===============================================================================

DROP TABLE IF EXISTS `transactions`;
DROP TABLE IF EXISTS `users`;

-- Users Table Schema
CREATE TABLE `users` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `uuid` VARCHAR(36) NOT NULL UNIQUE,
  `first_name` VARCHAR(50) NOT NULL,
  `last_name` VARCHAR(50) NOT NULL,
  `email` VARCHAR(100) NOT NULL UNIQUE,
  `role` VARCHAR(20) DEFAULT 'user',
  `status` VARCHAR(20) DEFAULT 'active',
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Seed data: Users
INSERT INTO `users` (`uuid`, `first_name`, `last_name`, `email`, `role`, `status`) VALUES
('e2b58d92-7f91-4d3e-908c-68748378d381', 'Alex', 'Rivera', '[email protected]', 'admin', 'active'),
('c8f1e2a3-9b8c-4d5e-a6f7-123456789abc', 'Elena', 'Yilmaz', '[email protected]', 'developer', 'active'),
('a1b2c3d4-e5f6-7a8b-9c0d-1e2f3a4b5c6d', 'Marcus', 'Vance', '[email protected]', 'user', 'active'),
('f9e8d7c6-b5a4-3f2e-1d0c-9b8a7f6e5d4c', 'Sophia', 'Chen', '[email protected]', 'user', 'pending'),
('d4c3b2a1-0f9e-8d7c-6b5a-4f3e2d1c0b9a', 'Liam', 'Connor', '[email protected]', 'user', 'suspended');

-- Transactions Table Schema
CREATE TABLE `transactions` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT NOT NULL,
  `amount` DECIMAL(10, 2) NOT NULL,
  `currency` VARCHAR(3) DEFAULT 'USD',
  `payment_method` VARCHAR(30) NOT NULL,
  `status` VARCHAR(20) DEFAULT 'completed',
  `transaction_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Seed data: Transactions
INSERT INTO `transactions` (`user_id`, `amount`, `currency`, `payment_method`, `status`) VALUES
(1, 149.99, 'USD', 'Credit Card', 'completed'),
(1, 29.50, 'USD', 'PayPal', 'completed'),
(2, 499.00, 'EUR', 'Stripe', 'completed'),
(3, 12.00, 'USD', 'Apple Pay', 'completed'),
(4, 85.75, 'USD', 'Credit Card', 'pending'),
(5, 230.00, 'USD', 'Bank Transfer', 'refunded');

Download Assets
Wait 10 sec
Free file download — fast & secure!
Download this open-source asset for free on Clayi Assets. Direct CDN link after a short wait — no account required.

New Resources

Popular Resources

There are no comments yet :(

Mock Users & Financial Transactions Database SQL Seed Dump
Tell us what you think about "Mock Users & Financial Transactions Database SQL Seed Dump"
Information
Users of Guests are not allowed to comment this publication.