show me an database schema like api2cart for sync multiple products, orders from…
- User
show me an database schema like api2cart for sync multiple products, orders from shopify, wordpress ecomerce...
- Assistant
show me an database schema like api2cart for sync multiple products, orders from shopify, wordpress ecomerce...
Certainly! Designing a database schema to synchronize products and orders from multiple e-commerce platforms like Shopify and WordPress (WooCommerce) requires a flexible and scalable structure. Below is a comprehensive database schema that can serve as a foundation for your synchronization system, similar to how API2Cart operates.
At a high level, the database schema includes the following main entities:
Stores information about each e-commerce platform you are integrating with.
| Field Name | Data Type | Constraints | Description |
|---|---|---|---|
| platform_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique identifier for each platform. |
| name | VARCHAR(100) | NOT NULL | Name of the platform (e.g., Shopify). |
| api_credentials | TEXT | NOT NULL | API keys and tokens (securely stored). |
| platform_url | VARCHAR(255) | Base URL of the platform's store. | |
| created_at | DATETIME | DEFAULT CURRENT_TIMESTAMP | Record creation timestamp. |
| updated_at | DATETIME | Last update timestamp. |
Holds product data from multiple platforms.
| Field Name | Data Type | Constraints | Description |
|---|---|---|---|
| product_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique internal identifier. |
| platform_id | INT | FOREIGN KEY -> Platforms(platform_id) | Associated platform. |
| external_product_id | VARCHAR(100) | NOT NULL | Platform-specific product ID. |
| sku | VARCHAR(100) | Stock keeping unit. | |
| name | VARCHAR(255) | NOT NULL | Product name. |
| description | TEXT | Product description. | |
| price | DECIMAL(10,2) | NOT NULL | Product price. |
| currency | VARCHAR(10) | NOT NULL | Currency code (e.g., USD). |
| stock_quantity | INT | Available stock. | |
| category_id | INT | FOREIGN KEY -> Categories(category_id) | Assigned category. |
| image_url | VARCHAR(255) | URL to product image. | |
| created_at | DATETIME | DEFAULT CURRENT_TIMESTAMP | Record creation timestamp. |
| updated_at | DATETIME | Last update timestamp. |
Manages product categories from different platforms.
| Field Name | Data Type | Constraints | Description |
|---|---|---|---|
| category_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique internal identifier. |
| platform_id | INT | FOREIGN KEY -> Platforms(platform_id) | Associated platform. |
| external_category_id | VARCHAR(100) | NOT NULL | Platform-specific category ID. |
| name | VARCHAR(255) | NOT NULL | Category name. |
| parent_category_id | INT | FOREIGN KEY -> Categories(category_id) | Parent category (self-referencing). |
| created_at | DATETIME | DEFAULT CURRENT_TIMESTAMP | Record creation timestamp. |
| updated_at | DATETIME | Last update timestamp. |
Stores customer information from various platforms.
| Field Name | Data Type | Constraints | Description |
|---|---|---|---|
| customer_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique internal identifier. |
| platform_id | INT | FOREIGN KEY -> Platforms(platform_id) | Associated platform. |
| external_customer_id | VARCHAR(100) | NOT NULL | Platform-specific customer ID. |
| first_name | VARCHAR(100) | Customer's first name. | |
| last_name | VARCHAR(100) | Customer's last name. | |
| VARCHAR(255) | Customer's email address. | ||
| phone | VARCHAR(50) | Customer's phone number. | |
| billing_address | TEXT | Billing address details. | |
| shipping_address | TEXT | Shipping address details. | |
| created_at | DATETIME | DEFAULT CURRENT_TIMESTAMP | Record creation timestamp. |
| updated_at | DATETIME | Last update timestamp. |
Captures order details from customers.
| Field Name | Data Type | Constraints | Description |
|---|---|---|---|
| order_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique internal identifier. |
| platform_id | INT | FOREIGN KEY -> Platforms(platform_id) | Associated platform. |
| external_order_id | VARCHAR(100) | NOT NULL | Platform-specific order ID. |
| customer_id | INT | FOREIGN KEY -> Customers(customer_id) | Customer who placed the order. |
| order_status | VARCHAR(50) | NOT NULL | Current status (e.g., Pending, Shipped). |
| total_amount | DECIMAL(10,2) | NOT NULL | Total order amount. |
| currency | VARCHAR(10) | NOT NULL | Currency code. |
| order_date | DATETIME | NOT NULL | Date and time when the order was placed. |
| created_at | DATETIME | DEFAULT CURRENT_TIMESTAMP | Record creation timestamp. |
| updated_at | DATETIME | Last update timestamp. |
Associates products with orders.
| Field Name | Data Type | Constraints | Description |
|---|---|---|---|
| order_item_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique internal identifier. |
| order_id | INT | FOREIGN KEY -> Orders(order_id) | Associated order. |
| product_id | INT | FOREIGN KEY -> Products(product_id) | Purchased product. |
| quantity | INT | NOT NULL | Quantity ordered. |
| price | DECIMAL(10,2) | NOT NULL | Price per unit at the time of order. |
| total | DECIMAL(10,2) | NOT NULL | Total price for this item (price * quantity). |
| created_at | DATETIME | DEFAULT CURRENT_TIMESTAMP | Record creation timestamp. |
| updated_at | DATETIME | Last update timestamp. |
Keeps track of product inventory across platforms.
| Field Name | Data Type | Constraints | Description |
|---|---|---|---|
| inventory_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique internal identifier. |
| product_id | INT | FOREIGN KEY -> Products(product_id) | Product reference. |
| platform_id | INT | FOREIGN KEY -> Platforms(platform_id) | Platform reference. |
| stock_quantity | INT | NOT NULL | Stock level on the platform. |
| updated_at | DATETIME | Last stock update timestamp. |
Records synchronization operations and errors.
| Field Name | Data Type | Constraints | Description |
|---|---|---|---|
| log_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique internal identifier. |
| platform_id | INT | FOREIGN KEY -> Platforms(platform_id) | Associated platform. |
| operation | VARCHAR(50) | NOT NULL | Operation type (e.g., 'sync', 'update'). |
| status | VARCHAR(20) | NOT NULL | Result status ('success', 'failure'). |
| message | TEXT | Details about the operation. | |
| timestamp | DATETIME | DEFAULT CURRENT_TIMESTAMP | Time of the log entry. |
platform_id foreign key.external_*_id fields store the unique identifiers from the respective platforms, ensuring that you can correlate records with the data in the external systems.platform_id and external_*_id, you prevent data collisions and maintain uniqueness across different platforms.parent_category_id allows for nested categories.external_*_id fields.Logs table for monitoring and debugging.external_*_id, platform_id, sku, and email to improve query performance.platform_id if dealing with a large volume of data.api_credentials using encryption mechanisms such as AES encryption.Platforms table and ensure your synchronization logic can handle the platform's API.Scenario: A product with SKU ABC123 exists on both Shopify and WooCommerce platforms.
SKU = ABC123, one for each platform, with different platform_id and external_product_id.api_credentials from the Platforms table to authenticate API requests.external_product_id and platform_id.Order_Items.Inventory table.Logs table.This database schema provides a robust framework for synchronizing products, orders, and associated data across multiple e-commerce platforms. It accommodates platform-specific requirements while maintaining a centralized view of all data.
By implementing this schema, you can:
If you have any questions or need further clarification on specific parts of the schema, feel free to ask!
Not yet included in a published release.