Saturday, January 31, 2015

Re: Is is possible to have a distributed database with Django?

Sure, it's possible. But this is a really hard problem. One way is to
let the database do all the heavy lifting. But you'll have to forget
about using simple databases like SQLite or MySQL. Oracle's advanced
replication documentation talks about exactly this type of situation
w/r/t materialized views:

https://docs.oracle.com/database/121/REPLN/repmview.htm#REPLN266

Another option is to do it all in the Django app. Your app would
probably always query and modify the local copy for end user requests.
Then there would be a separate portion of your app that runs in the
background on a schedule (management command? celery task?) that syncs
the local copy of the database with the master when it can.

But good luck getting all that logic correct. For simple projects you
might be able to, but add any sort of complexity and you're asking for
trouble. For instance: suppose your table has a unique constraint that
can be satisfied in the local DB but not the master DB. Are you ready
to throw away the local transactions that can't satisfy the
constraint?

But there are other types of constraints not included in the database
schema. For instance, let's say you have logic in your application so
that user Fred can destroy Widgets but only if he has the manager
permission. Fred gets demoted, but before the demotion is synced to
the local DB he goes through and destroys all the Widgets. How do you
keep that change from being propagated to the master DB when the next
sync happens?

The details of your particular app may make some of these questions
easier. Maybe not all of the DB needs to be read/write while in a
disconnected state. For example, consider a sales man going to a
remote location to talk to a client. He might be OK with readonly
copies of the master DB's Widget table, Contacts table, SLA table, etc
and only need an appendonly copy of the Orders table (that is, he can
read existing Orders, create/edit new Orders, but not edit existing
Orders). But you will still need reconciliation logic for when he gets
back in case the Widget or SLA he used in the Order no longer exists.


On Sat, Jan 31, 2015 at 10:04 AM, Itumeleng Mphoso <itumphoso@gmail.com> wrote:
> I'm new to Django and have just deployed my first Django application. My
> problem is, the application is used by people in different locations and
> networks, so when ever the network is down, those using a different network
> can't have access to the application. I need all the networks to have a
> local database that they use, but this database should also synchronize
> whenever they have internet. Is there anything I can do with Django to make
> this possible?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/450edd30-433b-4d4f-8e70-21f11369b7c5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD4ANxWDM3TQMSs4PNjMF22om9e5upo%3DBN5p6012GOB-KAm2YQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment