Thursday, July 18, 2019
Sql Programming Language
SQL is an abbreviation which stands for Structured Query Language. Some read and pronounced it as ââ¬Å"Sequelâ⬠while others pronounce it by reading the letters separately. SQL is a standardized query language used to retrieve information from databases. It was originally designed by International Business Machine (IBM) way back in the 70s and called its original version as SEQUEL (Structured English Query Language). Since then it has become the favorite query language for Database Management Systems running on minicomputers, mainframes, and Personal Computers up to the present.Query languages are computer languages used to make queries to database and information system ââ¬â taken from wikipedia. com. It supports databases that are spread out over several computers in a computer networks allowing transaction to take place between Server and Client computers. It is capable of handling simultaneous request from several users to access to database on a computer networks. One example of SQLââ¬â¢s application is on websites that allows users to register information and then do updates and search later on. SQL is the working on the background to handle everything that the user does though we cannot see it.In the year 1979 Oracle Corporation introduced SQL as the first commercial database management system. Taken from Webopedia. com http://www. webopedia. com/TERM/S/SQL. htm There are many versions of SQL nowadays for the fact that the language itself is still expanding and evolving. In 1986, SQL version complied with American National Standard Institute (ANSI), and in the following year 1987 with the International Standard Organization (ISO). Further development was made in the following years containing expansions and revisions of the relevant parts.Present versions of SQL compared to its old versions can already allow access to external data sources or Non-SQL data sources.IS SQL A PROGRAMMING LANGUAGE?Some people underrated SQL to be considered as a programming language. These people have forgotten to accept the definition itself which states that it is a language. When they talk of programming languages the first things that come to their minds are Assembly Language, Cobol, Fortran, Java, and C++. They insist that it is not compiled and contains lesser functions compared to the above mentioned languages.Yes, SQL is a programming language. The languages mentioned above are 3rd Generation and High-Level Languages which were invented to ease the problem of using complex commands which are hard to memorize and incomprehensible in forms. They are all designed for their own purpose. For instance Cobol is designed for business oriented applications, C is for system programming applications. SQL on the other hand is designed for data access. Data is the most valuable element in business systems and the need to be kept, retrieve, and manipulate. And SQL is there to help.Aside from being different in purpose, one feature of a programmi ng language is the replacement of words to Numeric commands. These are both features of the 3rd Generation and the 4th Generation languages. For instance, the machine code represented by a combination of bits 0ââ¬â¢s and 1ââ¬â¢s to look for file directories is replaced by using the English word ââ¬Å"Dirâ⬠. But if we will look at the syntax and forms that it takes it will still sound awkward English. If you are not familiar with ââ¬Å"Dirâ⬠you could still get confused with how you are going to use it. 3rd Generation and High-Level Languages are still far closer to the real human language.SQL on the other hand is a 4th Generation Language that is very close to the human language. For instance the SQL command ââ¬Å"UPDATE Employees SET lastname = ââ¬ËSequelââ¬â¢ WHERE fldidnumber = ââ¬Ë2000-c-0001ââ¬â¢Ã¢â¬ . The command resembles closely to an English sentence structure. It is much closer to human language to manipulate data so it eliminates the threa t of using the wrong command since the command itself is much easier to understand. What would happen if you see command that takes that form in future versions of C++, in Java and in other high level languages? Will you no longer consider them as a programming language?Another thing to remember is that these languages are now being used in combination in order to support the lacking capability of the other in completing a certain task. A programming language designed mainly for numeric calculations may find it hard to perform data access. What if a completion of task needs both data access and numeric calculations? The only solution is to consider using any possible combination between the two separately designed languages. That is why SQL commands are being embedded in some Non SQL Products. Do not underestimate the application of SQL for fast data access.We should remember that the main point of developing computer programming languages is to make data manipulation possible throu gh the use of computer. In order for data manipulation to be successful, computers must be instructed with particular sets of commands. These commands are coded or programmed by computer programmers that when once completed will enable data manipulation. These programmers works are often disrupted when they fail to recognize properly some of the machine based commands or partially human like words even though when given in full listings.If there is a programming language that offers much more readability then that would be best suited in situations like this, and the best example is the SQL. Maybe its less functionality comes from the fact that conversion of all machine based codes do not only took days, but perhaps decades. And that SQL is designed primarily for data access not for creation of another complex application. But it is the easiest one to use when dealing with data access and that is undeniable. That is why up to the present SQL is still being revised and expanded with other functionalities.In the end it is still a language and is considered 4th Generation languages.SQL COMMANDSTypes of SQL Commands Like other programming languages, SQL commands are categorized according to its functions. These functions include building database objects like tables and queries, manipulating objects, inserting data to existing tables, updating existing data in tables, deleting existing data from tables, performing database queries, controlling database access, and overall database administration. The main categories are:1. DDL (Data Definition Language)Data Definition Language, DDL, is consists of SQL commands that allows a user to create and restructure database objects, such as the creation or the deletion of a table. Examples of DDL Commands are:CREATE TABLE CommandTables in databases are the most basic structure where all information pertaining to particular records are stored in columns called fields. A table is composed of at least two or more columns or fie lds. Records expand in rows.Syntax: CREATE TABLE ââ¬Å"table_nameâ⬠(ââ¬Å"column 1â⬠ââ¬Å"data_type_for_column_1â⬠, ââ¬Å"column 2â⬠ââ¬Å"data_type_for_column_2â⬠, â⬠¦ )All you have to do is replace the portion ââ¬Å"table_nameâ⬠with the name of the table you will create, replace ââ¬Å"column1â⬠with the name of the first field followed by space and followed by data type of the first field.Example: CREATE TABLE Employee (FirstName char(40), LastName char(40), Address char(40), City char(50), Country char(25), Birth_Date date) ALTER TABLE Command This command is used to change a table structure.Syntax: ALTER TABLE ââ¬Å"table_nameâ⬠[alter specification] [alter specification] are listed below:For Adding new column: ADD ââ¬Å"NewColumnâ⬠ââ¬Å"data type for NewColumn 1â⬠.For Deleting or Dropping an existing column: DROP ââ¬Å"ColumnNameâ⬠.For Changing a column name: CHANGE ââ¬Å"OldColumnNameâ⬠ââ¬Å"NewC olumnNameâ⬠ââ¬Å"data type for NewColumnNameâ⬠.For Changing the data type for a column: MODIFY ââ¬Å"ColumnNameâ⬠ââ¬Å"newdatatypeâ⬠.Examples: If we want to add a column for Employee Status with data type Char: ALTER table Employee add Employee_Status char(1) To rename ââ¬Å"Employee_Statusâ⬠to ââ¬Å"EmpStatâ⬠: ALTER table Employee change Employee_Status EmpStat char(50)DROP TABLE CommandUsed to delete an existing table. Syntax; Drop ââ¬Å"tablenameâ⬠. Example: Drop Employee.CREATE INDEX CommandIndexes are created to make searches much faster. Most index are defined on fields which is mostly used for searching like the id number, or lastname fields.Syntax: CREATE INDEX ââ¬Å"index_nameâ⬠ON ââ¬Å"table_nameâ⬠(column_name).Example: CREATE INDEX ââ¬Å"idxFirstnameâ⬠ON ââ¬Å"Employeeâ⬠(Firstname)CREATE VIEW CommandViews are like tables, but they do not physically stores data which table does. Views only stores data temporarily.Syntax: CREATE VIEW ââ¬Å"VIEW_NAMEâ⬠AS ââ¬Å"SQL Statementâ⬠.Example: CREATE VIEW VwEmployee AS SELECT FirstName, LastName, Country FROM Employee.Other commands included in DDL are Drop View and Drop Index.2. DML (Data Manipulation Language)Data Manipulation Language, DML, is consists of SQL commands used to manipulate data within objects of a relational database. There are three basic DML commands listed below:INSERT CommandInsert command is used to add record to a datab ase table.Syntax: INSERT INTO ââ¬Å"tablenameâ⬠(ââ¬Å"column1â⬠, ââ¬Å"column2â⬠, â⬠¦ ) VALUES (ââ¬Å"value1â⬠, ââ¬Å"value2â⬠, â⬠¦ ).Example: INSERT INTO Employee (Firstname, Lastname, â⬠¦ ) VALUES (ââ¬ËJohnââ¬â¢,ââ¬â¢Mayerââ¬â¢).UPDATE CommandThis command is used to modify a certain record.Syntax: UPDATE ââ¬Å"tablenameâ⬠SET ââ¬Å"ColumnNameâ⬠= [new value] WHERE {condition}.Example: UPDATE Employee SET Lastname = ââ¬Å"Eckertâ⬠WHERE IdNumber = ââ¬Ë2000-c-0001ââ¬â¢.DELETE CommandThis command is used to delete records from a table.Syntax: DELETE FROM ââ¬Å"tablenameâ⬠WHERE {condition}.Example: DELETE FROM Employee WHERE IdNumber = ââ¬Ë2000-c-0001â⬠.3. DQL (Data Query Language)This command is used to retrieve from one or more tables in a database or from other databases.SELECT CommandSyntax: SELECT ââ¬Å"columnnameâ⬠FROM ââ¬Å"tablenameâ⬠.Example: To select only the firstname and the lastname fields of all records from table employee: SELECT Firstname, Lastname FROM Employee.4. DCL (Data Control Language)These commands allows user to configure how user can access the database. These DCL commands are normally used to create objects related to implement limitations to user access and also control the distribution of privileges among users.Example of these commands are listed below:ALTER PASSWORD GRANT REVOKE CREATE SYNONYMYou will find that these commands are often grouped with other commands and may appear in a number of different lessons throughout this book.5. Data administration commandsData administration commands allow the user to perform audits and perform analyses on operations within the database. They can also be used to help analyze system performance. Two general data administration commands are as follows: START AUDIT STOP AUDIT6. Transactional Control CommandsThese commands allows user to manage all database transactions that are taking place within a certain period of time.COMMIT ââ¬â this command confirms saving of all database transactions that were made by the userROLLBACK ââ¬â this command is used to scratch or undo all database transactions that were made by the userSAVEPOINT Used to create points within groups of transactions in which to be undone or ROLLBACKSET TRANSACTION Places a name on a transactionTHE IMPORTANCE OF SQL IN TODAYS BUSINESS APPLICATIONSTodayââ¬â¢s business organizations practice is far more different from the past. It is mostly characterized by the computerization of manual data processing, allowing online inquiries, buying, selling, payment, money transfers, social networking, and information sharing.Because data is the most important value for any organization, the demand in the use of SQL which is widely used in the past up to the present is expected to grow. With the expansion of SQLââ¬â¢s use from minicomputers, mainframes, PCs, Local Area Network, it is now working behind s ophisticated internet based applications. There is a huge demand in the development of these types of applications nowadays and the demand is predicted to grow in the years to come. There are recent effort to expand SQL for multimedia purposes. We will start checking the importance of SQL versions in todayââ¬â¢s business applications.Perhaps one of the most powerful features of SQL is its ability to support Server-Client transactions. This is made possible by using SQL Servers which allows database creation. This is what is being implemented in internet based application, in database systems in local area networks which allow several users to access data simultaneously. A Database is created on an SQL Server placed on Large Server Computers and the server is the one that will process the request from several clients. Several Versions of SQL Servers nowadays already have Graphical user Interfaces which allows point and click operation.Another feature of these servers are the capab ility to generate SQL commands which corresponds to a certain operation. This is very advantageous for users who are using only point and click option and then later on check what commands are actually done by that whole process. The point and click view is often called as Design View, while the SQL generated is called the SQL View. For example the creation by clicking a Create View Button in Design View will generate the Create View command that will be shown on SQL View.So it offers much more advantage for beginning SQL users to master SQL Commands, and for expert users to check their manually created SQL commands by comparing to the ones generated when using point and click option in Design View.REFERENCESPatrick O'Neil, ââ¬Å"Database Principles, Programming, Performanceâ⬠, Morgan Kaufmann 1994Elmasri & Navathe, ââ¬Å"Fundamentals of Database Systemsâ⬠, Benjamin/Cummings, 1994.Ramakrishnan, ââ¬Å"Database Management Systemsâ⬠, McGraw Hill, 1996.Date & Darwin, à ¢â¬Å"A Guide to the SQL Standardâ⬠, Fourth Edition, Addison-Wesley, 1993.Ullman & Widom, ââ¬Å"A First Course in Database Systemsâ⬠, Prentice Hall, 1997.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment