/
Data Model For Customers

What is the purpose of this article?

In this article contains all the data models required to achieve customer page requirement

 Database: eshopbox_wms_dev

Table Name: customers

Field

Datatype

Key


id

BIGINT(20)

Primary


brand_account_id

BIGINT(20)



name

VARCHAR(200)

 


phone

VARCHAR(20)

 


email

VARCHAR(255)

 


status

ENUM('ACTIVE', ‘ARCHIVED’, 'SUPPRESSED')

 


whatsappStatus

ENUM('ACTIVE', ‘INACTIVE', 'UNSUBSCRIBED’)

 


customerAdditionalInfo

TEXT

 


orderDetails

TEXT



createdBy

VARCHAR(200)



updatedBy

VARCHAR(200)



origin

VARCHAR(255)



createdAt

timestamp

 


updateAt

timestamp

 


SQL Query to create 'customers' table

1CREATE TABLE customers ( 2 id INT PRIMARY KEY AUTO_INCREMENT, 3 brand_account_id BIGINT(20), 4 name VARCHAR(255), 5 phone VARCHAR(20), 6 email VARCHAR(255), 7 status ENUM('ACTIVE', 'SUPPRESSED', 'ARCHIVED'), 8 whatsappStatus ENUM('ACTIVE', 'INACTIVE', 'UNSUBSCRIBED'), 9 customerAdditionalInfo TEXT, 10 orderDetails TEXT, 11 createdBy VARCHAR(255), 12 updatedBy VARCHAR(255), 13 origin VARCHAR(255), 14 createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 15 updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 16 FOREIGN KEY (brand_account_id) REFERENCES accounts(id) 17); 18 19 20



Database: eshopbox_wms_dev

Table Name: addresses

Field

Data Type

Key

id

BIGINT(20)

PRIMARY

customer_id

BIGINT(20)

FOREING KEY

address

TEXT

 

city

VARCHAR(100)

 

pincode

VARCHAR(10)

 

state

VARCHAR(100)

 

country

VARCHAR(100)

 

landmark

TEXT

 

createdAt

timestamp

 

updatedAt

timestamp

 

SQL Query to create ‘addresses’ table

1CREATE TABLE addresses ( 2 id BIGINT(20) PRIMARY KEY AUTO_INCREMENT, 3 customer_id BIGINT(20), 4 address TEXT, 5 city VARCHAR(100), 6 pincode VARCHAR(10), 7 state VARCHAR(100), 8 country VARCHAR(100), 9 landmark TEXT, 10 createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 11 updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 12 FOREIGN KEY (customer_id) REFERENCES customers(id) 13); 14