Nội dung text Unit IV - Relational Database Query Languages – Database Management System.pdf
www.ckundan.com.np 1 Unit IV: Relational Database Query Languages – Database Management System Introduction to SQL (Structured Query Language): SQL is just a query language; it is not a database. To perform SQL queries, we need to install any database, for example, Oracle, MySQL, MongoDB, PostGre SQL, SQL Server, DB2, etc. SQL stands for Structured Query Language. It is designed for managing data in a relational database management system (RDBMS). It is pronounced as S-Q-L or sometime See- Qwell. SQL is a database language, it is used for database creation, deletion, fetching rows, and modifying rows, etc. SQL is based on relational algebra and tuple relational calculus. All DBMS like MySQL, Oracle, MS Access, Sybase, Informix, PostgreSQL, and SQL Server use SQL as standard database language. Features of SQL: 1. High Performance: SQL provide high performance programming capability for highly transactional, heavy workload and high usage database system. SQL programming gives various ways to describe the data more analytically. 2. High Availability: SQL is compatible with databases like MS Access, Microsoft SQL Server, MySQL, Oracle Database, SAP HANA, SAP Adaptive Server, etc. All of these relational database management systems support SQL and it is easy to create an application extension for procedural programming and various other functions which is additional features thus converting SQL into a powerful tool. 3. Scalability and Flexibility: SQL provide Scalability and Flexibility. It is very easy to create new tables and previously created or not used tables can be dropped or deleted in a database.
www.ckundan.com.np 2 4. Robust Transactional Support: With SQL programming can handle large records and manage numerous transactions. 5. High Security: It is very easy to provide permissions on tables, procedures, and views hence SQL give security to your data. 6. Comprehensive Application Development: SQL is used by many programmers to program apps to access a database. No matter what is the size of organization, SQL works for every small or large organization. 7. Management Ease: SQL is used in almost every relational database management system. “Select“, “Create”, “Insert”, “Drop”, “Update”, and “Delete” are the standard and common SQL commands that helps us to manage large amount of data from a database very quickly and efficiently. 8. Open Source: SQL is an open-source programming language for building relational database management system Queries and Sub-Queries: Queries: In simple terms, we can explain query as questions or doubts. Query means finding information, asking questions about something, especially in order to express one's doubts about it or to check its validity or accuracy. A Query is used to traverse over some data may be of small or large quantity to find the needed information. We perform many queries in our day to day life. Asking questions is a form of query. Searching information on the web is a form of query. Looking for places on Map is a form of query. In each of these examples, we are looking for the required information in different ways. For asking questions we provide query in the form of voice while searching the web we enter keywords while looking for places on the map we enter the location. This is called
www.ckundan.com.np 3 a query language. A query language is a language which is used to specify our need in the retrieval procedures of information. A database also contains a lot of data. It stores data in the form of tables. This form of data is used in many places because of its various benefits. A database query refers to the request of data or information from a database. The database consists of tables which contain records of various entities. Thus a database query is used to query the records of a table. A database query is performed using a database query language which generates data of different types according to function. A number of query language have been developed for different database engines and purposes, one such language is SQL which is the most widely used and well-known database query language which generates result in the form of rows and columns. A database query can be of two types: 1. SELECT Query: A select query is used to retrieve data from a single table of a combination of multiple tables. SQL uses a SELECT statement to select, or extract, specific data based on the given base condition. 2. ACTION Query: The action query is used to perform operations on the database such as insertion, deletion, modification, alteration, etc. This query changes the database in one way or another. Sub-queries: A Subquery is a type of query which is written inside another query. A subquery becomes a part of a larger query. A subquery is also called INNER QUERY OR NESTED QUERY. A subquery provides data to the main query also called the parent query or outer query. A subquery is basically a SELECT statement that is embedded in a clause of another SQL statement. A subquery can be placed in SELECT clause, FROM Clause, WHERE Clause, HAVING Clause of the parent query or outer query. The inner query is executed once before its parent query so that the results of an inner query can be passed to the outer query. Syntax: SELECT select_list FROM table WHERE expr OPERATOR (SELECT select_list FROM table);