Best Way to Transfer Data to and from a MySQL Database - javascript

I wonder whether someone may be able to help me please. For a while now I've been working on the Javascript and HTML elements of the Google Maps V3 api. I now want to look at how I'm going to transfer the data to and from MySQL database.
I've read quite a lot of documentation on the Internet on the various methods of transferring this information but I'm not too sure of the best route to take.
I just wondered whether it would be possible that someone with a lot more experience than I could perhaps give me a bit of advice and direction please on the best way to transfer this data.
Many thanks and kind regards

it's a fairly broad question, but mostly dependent on your implementation. Are you already interfacing with the API using a server side language, or just all with Javascript? If everything is being done on the client side, then you would want to consider some sort of AJAX/form functionality to get the data from the client to a server side script. If you are doing any of this on the server side, then you can cut out the AJAX middle man and run SQL commands via PHP or whatnot as you are interfacing with the API.

I would recomend MySQl Dump. Its fairly simple and there is plenty of documentation on how to do it.

Related

Web site/app - Real-Time Charting Advice (mySQL, JS, PHP?)

I'm working on a project to create real-time charts from data in an SQL database. I've done a lot of research on JS charting libraries and have picked out a few good ones.
My problem is that I'm not sure how to get started with linking the SQL data to the web app/site.
My HTML and CSS are fine. I'm coming on with JS and we have software that provides me with necessary SQL query code.
Where is the gap in my knowledge? Is it necessary to learn PHP in order to get this working? How about C#?
My solution will currently be a locally hosted site, running on a networked computer (not currently got server space). The solution I have already uses Excel to query the database and runs a ton of macros to generate static charts every ten minutes. This works, but I'd like to create something far more flexible, robust and interactive.
Could anybody point me to any online resources that may help me? I like ChartJS but any open-source charting library will do. I'm hoping there's a great tutorial somewhere that covers SQL to real-time charts but I just can't find one...
If you want a real time charting you need to receive information from the DB almost every second. So sending a bunch of requests is not the best way to do this. You probably need to read about websockets and how do they work. Here is an example but you may find a lot more in google. If you don't want to do it with PHP, I can assure you that it would be far more easier with node.js

Social network architecture decision

As I can't orientate freely in the topic of building dynamic sites, it is quite hard to me to google this. So I'll try to explain the problem to you.
I'm developing a simple social network. I've built a basic PHP API represented by the files like "get_profile.php", "add_post.php", etc. with the POST method that is used to pass some data. Then I try to get the data using JS AJAX (php functions return it by JSON), which means I get all the data that I need to show on a page after the page is loaded. That causes decreasing of a page loading speed and I feel like this structure is really wrong.
I hope you'll explain me how to build a proper structure or at least give me some links to read. Thanks.
Populate the HTML with the (minimum) required data on the server side and load all other necessary data on the client side using AJAX (as you already do).
In any case, I would profile your application to find the most important bottle necks. Do you parallelize AJAX requests?
Facebook, for example, doesn't populate its HTML with the actual data on the server side, but provides the rough structure, which is later filled using AJAX requests.
If I understood your architecture right, it sounds ok.
Advices
Making your architecture similar to this allows you to deliver templates for the page structure that you then populate with data from your ajax request. This makes your server faster also since it doesn't have to render the HTML also.
Be careful with the amount of requests you make though, if each client makes a lot of them you will have a problem.
Try and break your application into different major pieces and treat each one in turn. This will allow you to separate them into modules later on. This practice is also referred as micro-services architecture.
After you broke them down try and figure user interaction and patterns. This will help you design your database and model in a way in which you can easily optimise for most frequest use-cases.
The way of the pros.
You should study how facebook is doing things. They are quite open about it.
For example, the BigPipe method is the fastest I have seen for loading a page.
Also, I think you should read a bit about RESTful applications and SOA type architectures.

DataBase Connectivity on the client side using (JavaScript)

I have a question which really Poked me for several days... I have came across a hurdle, the problem is that i need the Php application on the server side and the database to be on the client side... and the application should communicate with each other very nicely..
Javascript was the best option coming in my mind... The problem is that i dont have any idea how do i make this thing applicable...
If any one have any knowledge for that please share that stuff with me...
Thanks in advance...
Your question is kind of generic, so i can't determine whether you REALLY need a database stored on the client-side, and why. However if that is what you truly desire, HTML5 has client-side storage capabilities which can be used for running apps locally in the browser without having to pass data back to the server:
Some background and usage
Tutorial

Call server side C++ from webpage

I would like to use node.js/express and socket.io to retrieve data off of a piece of hardware through a web browser, but I really dont know where to start. I currently have express serving a webpage. I would like to retrieve and display raw data in realtime (graph form) from a sensor, for this reason, socket.io looked promising. I would also need to use some server side code (c, c++?) to do some processing on this data and display the results on the page. Is Ajax the best way to do this?
I do not really have much experience with this sort of thing, so is this the best way to go about this? Better options?
you can use web sockets and this c++ library. http://libwebsockets.org
and there is pretty example of its usage. http://martinsikora.com/libwebsockets-simple-http-server

Do I need server-end knowledge (e.g. Django, Rails), if I want to do Javascript, AJAX stuff?

I am trying to get into web development, specially interested building the front-end, UI part of websites while learning JavaScript maybe with AJAX technology. (I have a UI, HCI background.)
However, I have absolutely no previous knowledge about server-end web development either. To my understanding, frameworks like Django seem to pretty good at this (correct me if I am misunderstanding).
So the question is: how much Django, or Rails do I need to know, if my interest is primarily the user interface part of web development. Can I just let somebody else do the back-end stuff?
Pardon me for my imprecise choice of terminologies.
You need to know a bit about the server side. Here's what you need to know.
If you have a heavy JavaScript website, you're likely going to want to pass information from the server to clients with JSON (JavaScript Object Notation). This is just a way to format data into strings that JavaScript knows how to convert to objects.
So, each of your server-side functions that send data to the client will return JSON. If you have someone writing the server-side for you, that's all you should have to know. You're JS functions will receive JSON, and then you deal with it.
If you have to write the server-side yourself, then that involves 1) getting data from database 2) formatting the data 3) converting to JSON.
I have open-sourced a commenting widget that accepts JSON messages, and gives examples of how you would set up the Django server code. Maybe it will help you: http://www.trailbehind.com/comment_widget/
You can make a career of front-end user interface development without know a ton about server code. You would do well though to have at least a rudimentary understanding of what happens on the server when you send it a request, where your data comes from, and what the life-cycle of a web page is. This assumes that you have the support of back-end developers. As you mentioned Ajax in your question that implies that you want your web sites to actually do something, which will require things to happen on the back-end (such as storage, manipulation of data, logging in a user, etc.).
As with all things, the more you know, the easier it will be to get what you want from the dedicated professionals. I would suggest that you learn about programming in general, not try an learn a language and framework. In particular, try to understand datatypes, server settings (like timeouts, post versus get, etc.), security and database interactions as they exist beyond JavaScript/ECMAScript. That way when a developer is explaining why they cannot do something you have requested or are offering alternatives, you are speaking the same language.
Yes and no. Typically what people think of AJAX, such as posting a comment on YouTube and seeing the comment appear instantly with a thank you message, for example, requires a server side language handling the requests, looking up data and returning results as html snippets, JSON data, or XML.
However, an AJAX call can be made to static resources as well. You could have an XML file or html snippet stored statically on your web server and have it loaded. The uses for this sort of static loading are generally fewer because if you already have the static html or data in file next to your regular page, why not just put that data directly into the page?
It helps to set up a local server and write a few lines of code to service your AJAX calls. You can do a lot of JavaScript learning with just a little back-end learning.
If you're new in web development you'd rather wait with Ajax and server-side languages until you've learnt the basics with HTML, CSS and JavaScript, especially if you want to mostly work with the user interface and not the funcionality.
As you said you can let somebody else do the back-end and focus on front-end (JavaScript, HTML, CSS).
You would need to communicate with the back-end developer when storing or processing data from the server.
As mentioned before back-end development knowledge would be useful but if you have someone doing it, it's not essential for beginning.

Categories