THEN
As I understand the question, and correct me if I am wrong, it refers to the classic server model with JavaScript only in the client side. In this classic model, with LAMP servers (Linux, Apache, MySQL, PHP) the language in contact with the database is PHP, so to request data to the database you need to write PHP scripts and echo the returning data to the client. Basically, the languages distribution according to physical machines is:
- Server Side: PHP and MySQL.
- Client Side: HTML/CSS and JavaScript.
This responds to a MVC model (Model, View, Controller) where we have the following functionality:
- MODEL: The model is what deals with the data, in this case the PHP scripts that manage variables or that access data stored, in this case in our MySQL database and send it as JSON data to the client.
- VIEW: The view is what we see and it should be completely independent from the model. It just need to show the data contained in the model, but it shouldn't have relevant data on it. In this case the view use HTML and CSS. HTML to create the basic structure of the view, and CSS to give the shape to this basic structure.
- CONTROLLER: The controller is the interface between our model and our view. In this case the language used is JavaScript and it takes the data the model send us as a JSON package and put it inside the containers that offer the HTML structure. The way the controller interacts with the model is using AJAX. We use GET and POST methods to call PHP scripts in the server side and to catch the returned data from the server.
For the controller we have really interesting tools like jQuery, as "low level" library to control the HTML structure (DOM), and then new, more high level ones as Knockout.js that allow us to create observers that connect different DOM elements updating them when events occur. There is alsoAngular.js by Google that works in a similar way, but seems to be a more complete environment. To help you to choose among the, here there are two excellent analysis of the two tools: Knockout vs. Angular.js and Knockout.js vs. Angular.js. I am still reading. Hope them help you.
NOW
In modern servers based in Node.js, we use JavaScript for everything. Node.js is a JavaScript environment with many libraries that works with Google V8, Chrome JavaScript engine. The way we work with this new servers is:
- Node.js and Express: The main frame where the server is built. We can create a server with a few lines of code or even use libraries as Express to make even easier to create the server. With Node.js and Express we will manage the petitions to the server from the clients, and will answer them with the appropriate pages.
- Jade: To create the pages we use a templating language, in this case Jade, that allow us to write web pages as we were writing HTML but with differences (it take a little time but is easy to learn). Then, in the code of the server to answer the client petitions, we just need to render the Jade code into "real" HTML code.
- Stylus: Similar to Jade but for css. In this case, we use a middleware function to convert the stylus file into a real css file for our page.
Then we have a lot of packages we can install using the NPM (Node.js package manager) and use them directly in our Node.js server just requiring it (for those of you that want to lear Node.js, try thisbeginner tutorial for an overview). And among this packages you have some of them to access databases. Using this you can use JavaScript in the server side to access My SQL databases.
But the best you can do if you are going to work with Node.js is to use the new NoSQL databases likeMongoDB, based on JSON files. Instead of storing tables like MySQL, it stores the data in JSON structures, so you can put different data inside each structure like long numeric vectors instead creating hug tables for the size of the biggest one.
I hope this brief explanation becomes useful to you, and if you want to learn more about this, here you have some resources you can use:
- Code School: With a free and very interesting course about Chrome Developer tools to help you to test the client side.
- Codecademy: With free courses about HTML, CSS, JavaScript, jQuery and PHP that you can follow with online examples.
- 10gen Education: With everything you need to know about MongoDB in different tutorial for different languages.
- W3Schools: This one has different tutorial about all this and you can use it as a reference place because it has a lot of short code examples really useful.
- Udacity: A place with free video courses about different subjects with a few interesting one about web development and my preferred, an amazing WebGL course for 3D graphics with JavaScript.
Have fun!