Difference between revisions of "Oracle - Introduction"

From mi-linux
Jump to navigationJump to search
m (Protected "Oracle - Introduction" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
 
(20 intermediate revisions by the same user not shown)
Line 1: Line 1:
<h2>Introduction</h2>
+
[[Main Page]] >> [[Oracle|Oracle and SQL]] >> [[Oracle_Workbook|Workbook]] >> Introduction
 +
== Introduction ==
  
<p>The purpose of this module is to teach you about databases, in particular databases based on the relational model. The relational model is widely used in industry and many vendors provide relational products. Oracle, Microsoft Access and Visual FoxPro are three such products. SQL (Structure Query Language) is regarded as being the de facto query language for relational databases and this module uses Oracle as a vehicle for teaching SQL.</p>
+
The purpose of this module is to teach you about databases, in particular databases based on the relational model. The relational model is widely used in industry and many vendors provide relational products. Oracle, Microsoft Access and Visual FoxPro are three such products. SQL (Structure Query Language) is regarded as being the de facto query language for relational databases and this module uses Oracle as a vehicle for teaching SQL.
  
<p>SQL is subject to a number of standards: ANSI X3.135 - 1989; SQL2 (or SQL92) and SQL3 (SQL99) and recently SQL4 (2003). The current version of Oracle (version 12c) supports most of the SQL92 standard. It does also offer some support for objects, which is in the SQL99</p>
+
SQL is subject to a number of standards: ANSI X3.135 - 1989; SQL2 (or SQL92) and SQL3 (SQL99) and recently SQL4 (2003). The current version of Oracle (version 12c) supports most of the SQL92 standard. It does also offer some support for objects, which is in the SQL99.
  
<p>As you get more familiar with the product, you will come to realise that a lot of the commands detailed in this booklet could have been more easily entered/executed using the power tools. The purpose of the module is to teach you SQL which is standard across many relational products, e.g., Sysbase, Ingres, DB2. The Oracle Developer tools however are proprietary and every product has different tools. The commands in this booklet however can be executed on most relational platforms with little amendment; this would not be true if the toolset were used. </p>
+
As you get more familiar with the product, you will come to realise that a lot of the commands detailed in this booklet could have been more easily entered/executed using the power tools. The purpose of the module is to teach you SQL which is standard across many relational products, e.g., Sysbase, Ingres, DB2. The Oracle Developer tools however are proprietary and every product has different tools. The commands in this booklet however can be executed on most relational platforms with little amendment; this would not be true if the toolset were used.  
  
<h2>The Sample Relational Database</h2>
+
== The Sample Relational Database ==
  
<p>A relational database is a named collection of tables and other associated database objects (e.g., indexes, screens, menus, etc.). Typically a database management system (DBMS) can support more than one database simultaneously (or in ANSI-1989 terms, more than one environment). This allows the user to organise their tables into different databases if required. For example, you could have a different database for each module.</p>
+
A relational database is a named collection of tables and other associated database objects (e.g., indexes, screens, menus, etc.). Typically a database management system (DBMS) can support more than one database simultaneously (or in ANSI-1989 terms, more than one environment). This allows the user to organise their tables into different databases if required. For example, you could have a different database for each module.
<p>The following tables are used for illustrative purposes throughout the handout:</p>
+
 
<pre font = "red">
+
The following relational headings show the tables that are used for illustrative purposes throughout the handout:
EMP(<u>EMPNO</u>, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
+
 
DEPT(<u>DEPTNO</u>, DNAME, LOC)
+
<font face="verdana" color="purple">
SALGRADE(<u>GRADE</u>, LOSAL, HISAL)
+
EMP(<u>EMPNO</u>, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)<br/>
 +
DEPT(<u>DEPTNO</u>, DNAME, LOC)<br/>
 +
SALGRADE(<u>GRADE</u>, LOSAL, HISAL)<br/>
 
CUSTOMER(CNO, ORDERDATE, NAME, CITY, COUNTRY, PNO, DESCRIPTION, QTY)
 
CUSTOMER(CNO, ORDERDATE, NAME, CITY, COUNTRY, PNO, DESCRIPTION, QTY)
</pre>
+
</font>
<p>Where:
+
 
<ol>
+
Where:
<li>EMP contains information about the employees of a sample company</li>
+
 
<li>DEPT contains information about the departments in the company</li>
+
*EMP contains information about the employees of a sample company
<li>SALGRADE groups salary ranges into grades</li>
+
*DEPT contains information about the departments in the company
<li>CUSTOMER details information about the company's customers</li>
+
*SALGRADE groups salary ranges into grades
</ol>
+
*CUSTOMER details information about the company's customers (and is an example of a poorly designed table!)
</p
+
 
 +
A table is a two-dimensional, fixed length structure that holds information about something you wish to store data about, e.g., employees or customers. Each table will contain a number of records (also called rows or tuples), e.g., each employee will be represented as a single record in the EMP table and each record will contain a number of fields (also called columns or attributes), e.g., DEPT has the fields DEPTNO, DNAME and LOC. The relational model can be described in more formal terms, but for the moment let's keep things simple!
 +
 
 +
More specific constraints have been added to each table, constraints are a way of enforcing integrity rules on the data and include:
 +
<font face="verdana" color="blue">
 +
*The department name for the DEPT table (DNAME) must be entered
 +
*The manager number attribute (MGR) refers to another employee’s number. You will see in the sample data that employee 7566 (JONES) is managed by employee 7839 (KING)
 +
*An employee's salary must be entered and be greater than 0
 +
*An employee's commission may or may not be entered, but if it is must be greater than or equal to 0
 +
*An employee's department may or may not be entered, but if it is it must also exist in the department table DEPT
 +
*The low point of a salary grade (LOSAL) must be greater than 0
 +
*The high point of a salary grade (HISAL) must be greater than or equal to the low point
 +
</font>
 +
 
 +
All of this has been specified with NO traditional 3rd generation language programming. The database management system (DBMS) will enforce these constraints at all times.
 +
 
 +
== Next Step ==
 +
 
 +
Setting up [[Oracle_Getting_Started|the database]].

Latest revision as of 15:44, 24 February 2016

Main Page >> Oracle and SQL >> Workbook >> Introduction

Introduction

The purpose of this module is to teach you about databases, in particular databases based on the relational model. The relational model is widely used in industry and many vendors provide relational products. Oracle, Microsoft Access and Visual FoxPro are three such products. SQL (Structure Query Language) is regarded as being the de facto query language for relational databases and this module uses Oracle as a vehicle for teaching SQL.

SQL is subject to a number of standards: ANSI X3.135 - 1989; SQL2 (or SQL92) and SQL3 (SQL99) and recently SQL4 (2003). The current version of Oracle (version 12c) supports most of the SQL92 standard. It does also offer some support for objects, which is in the SQL99.

As you get more familiar with the product, you will come to realise that a lot of the commands detailed in this booklet could have been more easily entered/executed using the power tools. The purpose of the module is to teach you SQL which is standard across many relational products, e.g., Sysbase, Ingres, DB2. The Oracle Developer tools however are proprietary and every product has different tools. The commands in this booklet however can be executed on most relational platforms with little amendment; this would not be true if the toolset were used.

The Sample Relational Database

A relational database is a named collection of tables and other associated database objects (e.g., indexes, screens, menus, etc.). Typically a database management system (DBMS) can support more than one database simultaneously (or in ANSI-1989 terms, more than one environment). This allows the user to organise their tables into different databases if required. For example, you could have a different database for each module.

The following relational headings show the tables that are used for illustrative purposes throughout the handout:

EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
DEPT(DEPTNO, DNAME, LOC)
SALGRADE(GRADE, LOSAL, HISAL)
CUSTOMER(CNO, ORDERDATE, NAME, CITY, COUNTRY, PNO, DESCRIPTION, QTY)

Where:

  • EMP contains information about the employees of a sample company
  • DEPT contains information about the departments in the company
  • SALGRADE groups salary ranges into grades
  • CUSTOMER details information about the company's customers (and is an example of a poorly designed table!)

A table is a two-dimensional, fixed length structure that holds information about something you wish to store data about, e.g., employees or customers. Each table will contain a number of records (also called rows or tuples), e.g., each employee will be represented as a single record in the EMP table and each record will contain a number of fields (also called columns or attributes), e.g., DEPT has the fields DEPTNO, DNAME and LOC. The relational model can be described in more formal terms, but for the moment let's keep things simple!

More specific constraints have been added to each table, constraints are a way of enforcing integrity rules on the data and include:

  • The department name for the DEPT table (DNAME) must be entered
  • The manager number attribute (MGR) refers to another employee’s number. You will see in the sample data that employee 7566 (JONES) is managed by employee 7839 (KING)
  • An employee's salary must be entered and be greater than 0
  • An employee's commission may or may not be entered, but if it is must be greater than or equal to 0
  • An employee's department may or may not be entered, but if it is it must also exist in the department table DEPT
  • The low point of a salary grade (LOSAL) must be greater than 0
  • The high point of a salary grade (HISAL) must be greater than or equal to the low point

All of this has been specified with NO traditional 3rd generation language programming. The database management system (DBMS) will enforce these constraints at all times.

Next Step

Setting up the database.