B4J Question Advice needed: setup a cloud database solution

jmon

Well-Known Member
Licensed User
Longtime User
Hello,

I need to setup a simple client / server solution to send data to a server.
drawing.jpg


The connection is 1 way only: devices-->server. When the server receives data, the server will have to start a process, and no need to notify back the Devices. The data will be sent every 5 minutes.

The data that I need to send is simple data: Strings (Name, Email, Shipping Address ...) and number (prices, number of errors, boolean values, ...etc...). On each device, the users will create "clients" lists, and sync each client to the server:
i.e: name:john, age:35, shipping:USA ....

I would like to ask the community what would you recommend, considering that I need this:
  1. Close to realtime database, preferably less than 5 minutes to sync data.
  2. Offline / Online support, in case devices don't have internet connection, data should be synced at a later point. [edit: devices will be offline very often]
  3. Event notification when a new data is received
  4. Simple to setup (I don't want to install Mysql or other external applications)
  5. portable and backup-able
  6. statistics would be a big plus, like knowing total sales per month ...etc...
From what I saw, the best solution would be Firebase Realtime DB, but I've tried and failed so far to wrap the library.

The other best solution is Cloud KVS, but I wonder if in it's current state I could store all the data that I need to store for each client. I'm mostly wondering how would you guys structure the data?:
Store a map?
B4X:
ckvs.Put("User1", "data", CreateMap("name":"john", "age":35, "shipping":"USA"))
Store individual data?
B4X:
ckvs.Put("User1", "name", "john")
ckvs.Put("User1", "age", 35)
ckvs.Put("User1", "shipping", "USA")
Serialize the data?
B4X:
dim m as map = CreateMap("name":"john", "age":35, "shipping":"USA")
Dim ser As B4XSerializator
ckvs.Put("User1", "data", ser.ConvertObjectToBytes(m))

The only problem that I see with cKVS, is that the data is not stored in columns, thus making it difficult to do statistics, for example:
B4X:
SELECT SUM(price) GROUP by MONTH(date)

As I haven't done -cloud- projects like this in the past (only LAN projects), I have no idea about the problems that could arise in the future. In the past I started some B4J projects with wrong libraries or not knowing some concepts from the start (i.e. not knowing about B4XSerializator), and I want to avoid making mistakes for this one. What do you think? Is there any other solution that I missed?

Thanks for your help.
jmon
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
CloudKVS can be a good option. Don't serialize the data yourself as it is serialized internally anyway.

I think that storing the data in a map is better though both options are possible.

You will need to implement the analytics logic in your code. You can create a B4J client program that runs on the same computer as the server (or on a different computer) and it will add the data to a regular database.
 
Upvote 0
Top