Click here to load reader

SQL Queries funda

  • View

  • Download

Embed Size (px)

Text of SQL Queries funda

DataA collection of facts from which conclusions may be drawn; In computer science, data is any information in a form suitable for use with a computer. Database A database is a collection of data that is organized so that its contents can easily be accessed, managed, and updated. The most prevalent type of database RDBMS & DBMS RDBMS is a Relational Data Base Management System Relational DBMS. This adds the additional condition that the system supports a tabular structure for the ... A DBMS also has to provide some uniform methods independent of a specific application for accessing the information that is stored.

Cardinality In mathematics, the cardinality of a set is a measure of the "number of elements of the set".Cardinality is a facet on a slot on a class. Cardinality represents the exact number of valueswhich should be on that slot for that class. The number of rows in a table or the number of indexed entries in a defined index.

Codd's 12 rules Codd's 12 rules are a set of 12 rules proposed by Edgar F. Codd, a pioneer of the relational model for databases, designed to define what is required from a database management system in order for it to be considered relational, i.e., an RDBMS. [1][2] Codd produced these rules as part of a personal campaign to prevent his vision of the relational database being diluted, as database vendors scrambled in the early 1980s to repackage existing products with a relational veneer. Rule 12 was particularly designed to counter such a positioning. In fact, the rules are so strict that all popular so-called "relational" DBMSs fail on many of the criteria

The rulesRule 000: The system must qualify as relational, as a database, and as a management system.

For a system to qualify as a relational database management system (RDBMS), that system must use its relational facilities (exclusively) to manage the database. Rule 1: The information rule: All information in the database is to be represented in one and only one way, namely by values in column positions within rows of tables. Rule 2: The guaranteed access rule: All data must be accessible with no ambiguity. This rule is essentially a restatement of the fundamental requirement for primary keys. It says that every individual scalar value in the database must be logically addressable by specifying the name of the containing table, the name of the containing column and the primary key value of the containing row. Rule 3: Systematic treatment of null values: The DBMS must allow each field to remain null (or empty). Specifically, it must support a representation of "missing information and inapplicable information" that is systematic, distinct from all regular values (for example, "distinct from zero or any other number," in the case of numeric values), and independent of data type. It is also implied that such representations must be manipulated by the DBMS in a systematic way. Rule 4: Active online catalog based on the relational model: The system must support an online, inline, relational catalog that is accessible to authorized users by means of their regular query language. That is, users must be able to access the database's structure (catalog) using the same query language that they use to access the database's data. Rule 5: The comprehensive data sublanguage rule: The system must support at least one relational language that (a) Has a linear syntax (b) Can be used both interactively and within application programs, (c) Supports data definition operations (including view definitions), data manipulation operations (update as well as retrieval), security and integrity constraints, and transaction management operations (begin, commit, and rollback).

Rule 6: The view updating rule: All views that are theoretically updatable must be updatable by the system. Rule 7: High-level insert, update, and delete: The system must support set-at-a-time insert, update, and delete operators. This means that data can be retrieved from a relational database in sets constructed of data from multiple rows and/or multiple tables. This rule states that insert, update, and delete operations should be supported for any retrievable set rather than just for a single row in a single table. Rule 8: Physical data independence: Changes to the physical level (how the data is stored, whether in arrays or linked lists etc.) must not require a change to an application based on the structure. Rule 9: Logical data independence: Changes to the logical level (tables, columns, rows, and so on) must not require a change to an application based on the structure. Logical data independence is more difficult to achieve than physical data independence. Rule 10: Integrity independence: Integrity constraints must be specified separately from application programs and stored in the catalog. It must be possible to change such constraints as and when appropriate without unnecessarily affecting existing applications. Rule 11: Distribution independence: The distribution of portions of the database to various locations should be invisible to users of the database. Existing applications should continue to operate successfully : (a) when a distributed version of the DBMS is first introduced; and (b) when existing distributed data are redistributed around the system. Rule 12: The nonsubversion rule: If the system provides a low-level (record-at-a-time) interface, then that interface cannot be used to subvert the system, for example, bypassing a relational security or integrity constraint.

Some of Oracle's tools to access the database and create programs are: SQL*Plus has a command line interface. With it, you can access the database and write stored procedures, you can run SQL commands to retrieve data and you can run scripts of either SQL, PL/SQL or built-in SQL*Plus commands, or a mixture of those three things. Oracle Developer is a 4GL GUI application Builder. With Developer, you can create forms, reports, and graphics. Oracle*Forms and Oracle*Reports are two components of Oracle Developer. Earlier versions created client-server applications, but the more recent versions create web applications that run under the Oracle Application Server (OAS). OAS is a web-based application server sold by Oracle. OAS is licensed separately and is very expensive (as are its closed source competitors). The current version is OAS 10g. HTML DB is a fairly new application builder geared toward web development (added to the DB with release 9iR2). HTML DB does not need an application server. This tool runs from the database and can be presented to the web using the Apache web server that comes with the database. Since this is not an additional license, it provides a cheaper way to develop applications. Developer is a feature-rich thick client with all of the normal GUI widgets. HTML DB is HTML-based and is very thin and limited to the HTML provided widgets. Oracle Enterprise Manager (OEM) is the Enterprise GUI tool to manage the database. From this tool, you can perform any action in the database that is required. This tool is primarily used for administration but can also be provided to developers for application tuning and monitoring. In Oracle 10g, OEM also provides Grid control.

What is SQL, how is it pronounced, and where did it come from?SQL is the acronym for Structured Query Language. It is a data retrieval and manipulation language. It is usually pronounced as "es-que-el" or "sequel". I pronounce it both ways and my ears don't even notice a difference anymore. SQL came from Dr. EF Codd in the late 60's and was embraced by scientists at IBM including RF Boyce (ever heard of Boyce-Codd Normal Form (BCNF)?). Though IBM (as it has done with most computer technology) was a heavy lifter making SQL a workable language, it was not the first to really exploit it (as with most of its computer technology). No, it was good old Oracle that released the first commercial product based on SQL. And, since Oracle's earliest customer was the U.S. Government, the popularity of SQL and Oracle was secured. Standard SQL is characterized by its ease of use and great power in basic operations. Because it does not really excel at advanced analytics, each vendor invariably creates its own extensions to ANSI SQL. Oracle is no exception. Where, in some technologies, being 100% ANSI or ISO compliant can be a good thing, it's usually not in the world of RDBMS's. This is largely because of the architectural differences of the various RDBMS platforms.

Why use SQL? It is the most powerful and flexible tool available for dealing with databases. Why do some people hate SQL? Because they are (lazy?)...(stupid?)... it's hard to find a nice word, but I'll say they are just ignorant. Many developers think SQL is universal or at least should be. They understand perfectly that you can't take VB code and get a Java compiler to compile it, but they don't understand that 2 databases can have even slight variations. As a result, they try to keep their DATABASE application code DATABASE agnostic and then say a lot of silly things like "Oracle sucks." We'll discuss re-educating developers (they want to succeed as much as you do) later. In the next few posts, we'll go over how to use SQL and how Oracle handles it.

How runs. (PROCESS)-Translate the statement and verify the syntax is valid -check the data dictionary and make sure the referenced objects exist -get parsing locks on all required objects so the definitions don't change -check and make sure the executing user has privileges to the objects -figure out the best way (execution plan) to perform the request -load all this into a shared SQL area so others won't have to get this far -(route distributed statements) There are 3 things Oracle needs to know from your statment in order to run: What Where (don't confuse with WHERE-clause) When (because the WHERE-clause goes here) like do something over there when it

Search related