Sql ch 1


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Sql ch 1

  1. 1. Introduction to SQL – Ch 1 An Introduction to SQL1. What is SQL? (i) SQL is a tool for organizing, managing, & retrieving data stored in a database. (ii) The name "SQL" is the short form of Structured Query Language. (iii) SQL is a computer language that you use to interact with a database. (iv) SQL works with one specific type of database, called relational database.2. How does SQL work? Consider a computer system that has a database. (i) If the computer system is in a business, the database may store inventory, production, sales, or payroll data. On a personal computer, the database might store data about the checks you have written, lists of people and their phone numbers, or data extracted from a larger computer system. (ii) The computer program that controls the database is called a database management system, or DBMS. (iii) When we need to retrieve data from a database, we use the SQL language to make the request. The DBMS processes the SQL request, retrieves the requested data, and returns it to us. (iv) This process of requesting data from a database and receiving back the results is called a database query—hence the name Structured Query Language.3. What are the functions of SQL? OR What are the tasks carried out by SQL? SQL provides the following facilities / functions: (i) Data definition. SQL lets a user define the structure and organization of the stored data and relationships among the stored data items. (ii) Data retrieval. SQL allows a user or an application program to retrieve stored data from the database and use it. (iii) Data manipulation. SQL allows a user or an application program to update the database by adding new data, removing old data, and modifying previously stored data. (iv) Access control. SQL can be used to restrict which users can perform which operations on a database. E.g., certain users may be allowed only to retrieve data, while others can only add data, and still others may have permission to modifyProf. Mukesh N. Tekwani Page 1 of 4
  2. 2. Introduction to SQL – Ch 1 data. Thus, SQL can prevent unauthorized access. (v) Data sharing. SQL allows many users to share the same data, ensuring that they do not interfere with one another. (vi) Data integrity. SQL defines integrity constraints in the database, protecting it from corruption due to inconsistent updates or system failures.4 Is SQL similar to programming languages like C, C++, or Java? Justify (or explain) your answer SQL stands for Structured Query Language but SQL is not a programming language in the same category as C, C++ or Java. This is because: (i) SQL does not contain an “if” statement for testing conditions. (ii) SQL does not have control transfer statement such as the “goto” statement of C and C++. (iii) SQL does not have looping structures such as “for” statement. (iv) SQL is strictly speaking, a database sub-language. It contains about 40 statements which can be only used for database management tasks. (v) SQL statements can be embedded in programs written in other languages such as C, C++, or even in Excel spreadsheet so that it can access a database. (vi) SQL commands can also be sent directly to a database management system for processing. (vii) SQL is not structured like high level languages such as C or Java. SQL statements look like English sentences and a few words are even added to SQL statements only to make them more readable.5 What is the role of SQL in a database management system? (i) SQL is not a database management system. It is a part of the database management software. It is a tool for communicating with the DBMS. (ii) The typical components of a DBMS are Report Writer, database front-end, forms facility, and application programs. The heart of the DBMS is the database engine. It is responsible for structuring, storing and retrieving data in the database. (iii) The database engine accepts SQL requests from other DBMS components. (iv) SQL can be thought of as the glue that links together the various components of a DBMS.Page 2 of 4 mukeshtekwani@hotmail.com
  3. 3. Introduction to SQL – Ch 1 (v) SQL is an interactive query language. Users type SQL commands into an interactive SQL program to retrieve data and display it on the screen. (vi) SQL is a database programming language. SQL commands can be put into application programs to access the data in a database. (vii) SQL is a database administration language. The database administrator responsible for managing a database uses SQL to define the database structure and control access to the stored data. (viii) SQL is a client/server language. SQL is sued to communicate over a network with database servers that store shared data. (ix) SQL is an Internet data access language. Internet web servers and Internet applications servers use SQL for accessing databases. (x) SQL is a distributed database language. In a distributed database, data is spread out among many computer systems. SQL is used in such distributed database systems. The DBMS software on each system uses SQL to communicate with the other systems, sending requests for data access. (xi) SQL is a database gateway language. Computer networks use different DBMS products. SQL is used to access data form heterogeneous databases. (i.e., databases of different brands).6 State the major features of SQL OR State the reasons for success of SQL as a database language. The major features which are responsible for the success of SQL are: (i) Easy to understand and learn; the learning curve is not very steep. (ii) SQL statements look like simple English statements. These statements are easy to learn and understand. E.g. SELECT .. FROM .. clause (iii) It is an interactive query language. It is easy to write simple and small queries in SQL to access data rather than write complicated programs in a high-level programming language. (iv) It can be used with ad-hoc queries. Because of this, data is more accessible. (v) It can be used to programmatically access data. The same SQL statements can be used both interactively and through a program to access data in a database. (vi) SQL is a language for relational databases. The row/column structure of a database is easy to understand.Prof. Mukesh N. Tekwani Page 3 of 4
  4. 4. Introduction to SQL – Ch 1 (vii) SQL is portable among different computer systems. SQL-based computer systems can run on different types of computers from mainframe to desktop PCs. (viii) It can offer multiple views of data. The database administrator can offer different views of the same database to different users. Data from several databases can be combined and presented to the user as a simple row/column table. (ix) SQL is a complete database language. SQL can be used for creating a database, updating it, sharing data among users, retrieving data, and managing its security. (x) Using SQL, the structure of a database can be changed and expanded dynamically, even while users are accessing database contents. Thus, SQL has a dynamic data definition. (xi) It has the client/serer architecture. (xii) SQL permits access to Internet databases. (xiii) It is closely integrated with Java through JDBC (Java Data Base Connectivity). Through JDBC, Java programs can use SQL for accessing a database. (xiv) It is vendor independent. All database systems support SQL. (xv) SQL has the support of industry leaders IBM and Microsoft. Through ODBC, Microsoft products can access databases.Page 4 of 4 mukeshtekwani@hotmail.com