The central database(blue) will hold all customer data of the project.
The local databases(green) will be deployed at the physical locations containing a copy of the customer databases. Multiple stores can be deployed across geographical areas (A, B,...N) to allow customers to register and make purchases.
When a customer is registered at a local store, it should be updated in the central database with the purchase history. When a customer is registered, his purchase history should also be available in other stores.
For example, in the morning, a customer can purchase from store A, and afterward, customers should be able to purchase from store B/C or any other without registering again.
MySQL will be used as the database.
Advise is expected,
Is there a database architecture or pattern that we can
achieve this?
What's the best approach to implement this?
Referred: Database Architecture, Central and/vs Localized Server
There are three popular replication algorithms according:
single-leader. When just there is one leader node
multi-leader. When there are many leader nodes
leadeless. When there is no leader node
Read more about these algorithms in "Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems" by Martin Kleppmann. As a quick overview, you can read this article "Database replication — an overview".
When a customer is registered at a local store, it should be updated in the central database with the purchase history. When a customer is registered, his purchase history should also be available in other stores.
It looks like you need to use master-master replication or multi-master or multi-leader replication. As wiki says:
Multi-master replication is a method of database replication which
allows data to be stored by a group of computers, and updated by any
member of the group. All members are responsive to client data
queries. The multi-master replication system is responsible for
propagating the data modifications made by each member to the rest of
the group and resolving any conflicts that might arise between
concurrent changes made by different members.
And MySql supports this:
MySQL Group Replication is a MySQL Server plugin that enables you to
create elastic, highly-available, fault-tolerant replication
topologies.
Groups can operate in a single-primary mode with automatic primary
election, where only one server accepts updates at a time.
Alternatively, for more advanced users, groups can be deployed in multi-primary mode, where all servers can accept updates, even if they
are issued concurrently
I highly recommend you to read chapter "Replication" of book "Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems" by Martin Kleppmann
Short Answer: Nothing standard within MySQL.
Long Answer: It is a tough problem because of network outages, temporary server outages, etc.
Partial solutions:
The "right" answer is to have every "customer" not have its own database, but instead, do all reads and writes on the "Main computer".
To have only local data on each "customer" db (which would be a Primary), the Main could be a Replica receiving updates from each customer. But this says that the only complete copy is on Main.
To have each customer have all the data, you must write to main (Primary) and read locally (Replica).
I'm creating an application where each business will have;
owner which is a user at some-business-name database,
Some information about the business (This part will actually change my app's UI)
employees(Also users same as owner)
permissions (for employees. permissions for owner can't changed)
customers (Every business have customers)
... and such
I need a new database for each business with a unique business name for database name
Is there a limit to the number of databases in AWS RDS for MYSQL? if so how can i solve this problem?
NOTE: I have to create this application using aws
Take a look at the FAQs for RDS, looking at the "How many databases or schemas can I run within a DB instance?" section. According to that:
RDS for MySQL: No limit imposed by software
EDIT
You asked in the comments if this is suitable for your application. I have personally always found the "one environment per client" setup to be challenging. You must have good database upgrade scripts and code practices. Debugging a single client means understand the code that they run and the schema that they have. A multi-tenant solution can be easier but comes with it's own set of challenges when partitioning database data between customers. Yes, your solution will work. You don't mention the server side other than the CDK but if you're going to also partition the code this way it becomes very difficult to know which client is running what software.
Regardless of how you decide to do this keep good information about each client and what version of the software and the database they are using. Hopefully the software you're using auto-updates schemas as needed.
i have a paid app my database is MYSQL, i wanna know how many devices is logeed in in the same time with the same USER & PASS
any idea?
You should save the device id, platform, os version and other almost unique device's information in the database when the user logins. After that you can distinguish how many devices are logged with same login and password.
P.s. do not forget remove save devices data from database when user log out
I have a durable product. It purchasing correct and handling with CurrentApp.LicenseInformation.ProductLicenses too. But after application update system "loses" information about purchases.
I may call CurrentApp.RequestProductPurchaseAsync() again and user will just accept the message that the product was bought. But this is quite inconvenience. Is there a way to restore in-app purchases after update (beside saving this information into settings)?
User can purchase durable product from my app. If he uninstalled my app and then reinstall and he will lose all purchased information. Now if he want to buy it again, how is it possible? if possible, how to implement it???
All windows phone real money products should be WP App Store purchases. If it is not a real money product you can sync purchases via internet. It is not possible to keep any information locally between the two installations of the application.