• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook pagefor updates, or we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.)

[Guide] Many of you do not understand sql server..so here are a few tips

Experienced Elementalist
Joined
Apr 16, 2007
Messages
266
Reaction score
61
SQL Server is the software that manages all the data transactions between the client and the server files.

It records everything, your level, your items, your guild, etc.

So it becomes very important to work with it wisely.

That means, when you create php pages, make sure you keep in mind security and performance when you write sql queries.

Learn how to use views and stored procedures.

A basic query is like this.

select first_name, last_name
from table

A query that does a join is like this

select a.first_name, a.last_name, b.email
from table a inner join table b on b.id = a.id
order by a.last_name desc, a.first_name asc

So that's a basic joined table, that gets data from a table that has names, and a seperate table that has just email addresses.

These are just examples.

However, when you do queries that have complex joins, or require massive looping, in php or any other programming language, that makes it slower, and far less speedy.

so what you do is save the query in a view.

create view view_name
as
select a.first_name, a.last_name, b.email
from table a inner join table b on b.id = a.id
order by a.last_name desc, a.first_name asc

The only thing you need to consider is, if you need to do any where clause in php, if so, to make sure the fields in the select include the fields you need for any external where or order by.

A view is faster because it has sql server do all the joining, and then you just grab the results.

A stored procedure is more complex than a view.

A stored procedure is like a programming language, you can do views, loops, queries, do calculations, logic, etc.

In fact there are already a lot of built in stored procedures in kalonline.

For example if you have a php page/app that needs to do a lot of logic and querying and looping, you might want to create a stored procedure instead.

See the thing is you need to understand that each step on the process of delivering web-content to you, adds more to the load time.

There's javascript/css, then images, then actual html, tables, layout, fonts, colors.

But on the server side, php has to interact with sql server or mysql, as well as the web server to handle all those requests.

So by doing some work on the sql server side you can push more of the load to sql server, so it can do what it's great at.

And let php do what it's great at.

Sql Server can not do everything, but if you know it well, you can have a much more secure and stable server.

The main point of this post was to encourage you all to use a web-based tool like phpmyadmin for mysql, but here are a few that do it for sql server.

Because if you are remoting into a server, then loading sql server studio manager, that can add extra memory/cpu usage to the server that is just unneccessary.

where as a web-based interface will be faster loading, and you don't need to be so load intensive when trying to do work on the server.





(not free)

 
Back
Top