javascript - one query from multiple APIs -
is possible create 1 query api's different sources? ie,
in traditional web development if have next modules:
clients: clientid, clientname orders: ordersid, clientidi create 2 tables in 1 database , foreign keys joins , create query.
what instead of 1 database create 2 databases, 1 each module (this way can expand each module it's own entity easier) , "tie" 2 databases through apis.
so, still utilize "foreign keys" (ie, clientid in orders table) "tie" clients , orders, not "join" them because not in same database.
so, in interface have a:
client api http:mysite.com/showallclientsapi ordersapi http:mysite.com/showallordersapihow query (or possible) though apis between modules response:
salea clientname 1 clientname 2 etc saleb clientname 1 clientname 3i show orders(http://mysite.com/showsalesapi) have clientid=1 give me json response clientid , not clientname.
does create sense?
(you might inquire why want this. part of multi module application create sense maintain modules separate part of huge database, future development or interaction other applications)
any thoughts?
i thought of splitting out databases , putting them behind services, think should done care. if going joins between clients , orders, why create them communicate via services?
some thoughts:
maybe replicate info server server client/order queries can happen quickly. way each server still authoritative.
you can bring together entities in code of course. write wrappers sit down on top of each api , (c#):
list clientnames = new list(); var orders = orderservice.getorders(); foreach (var order in orders) { var client = clientservice.getclient(order.clientid); clientnames.add(client.firstname + " " + client.lastname); }
(note: inefficient, might want pass list of client ids)
something above phone call 2 services in simple way , "join" them in application. if feels much work, consider replication! =)
use mule (http://www.mulesoft.org/) handle integration of services. mule can create endpoints rest services (or http web service) , bring together them 1 "message".
no matter do, if split info across servers, going pay little higher cost queries. can't imagine performance anywhere near if entities on same server/database.
javascript api web-applications
No comments:
Post a Comment