Download presentation
Presentation is loading. Please wait.
Published byDonald Hudson Modified over 8 years ago
1
Introduction to Oracle
2
Before Computerized Database Organization use a set of data files to store each individual data. – The file contains individual fields or columns, such as ID’s, names, age, address, etc. As applications became more complex, it was hard to maintain data stored in a file. – One problem was proliferation of data management, where new entries needs it’s own field or columns.
3
Birth of Database To solve problems with data files, programmers developed database to store and manage application data. DATABASE Nowadays, organizations use database to store and maintain data in an organized way. Database stores all organizational data in a central location, which tries to eliminate redundancies to reduce the possibility of inconsistent data.
4
DBMS A single application called the Database management system is use to perform all routine data-handling in a database system. A common set of functions such as inserting, updating, deleting, and retrieving data values are provided to perform DBMS task.
5
Different data models Flat file system Sequential Hierarchical networked Relational data model
6
Relational Database Relational Database, stores data in a tabular format. – All data are organized in tables, or matrixes with rows and columns. – Columns represent different data fields or attributes about the entity. – Rows contains individual records or tuples of values of attributes.
7
Ideal Relational DB requirements Data saved in the databases represent facts and values of the real world. No duplicated rows are allowed. Order of rows is insignificant Order of attributes is insignificant
8
The Five Different terms involving Keys Primary Key – Uniquely identifies a record. – Example: employee’s social security number Candidate Key Composite Key Surrogate Key Foreign Key – A relationship can be created among different entities through key fields.
9
Primary Key This is the column whose value must be unique for each row. – It serves to uniquely identify a record, i.e. the individual occurrence of an entity. – For example, employee’s social security number – Every row must have a primary key and can not be NULL – A column containing numerical data or abbreviated code are the best choice for primary key in a data.
10
Candidate Key A candidate key is any column that could be used as the primary key. – It has to be a unique column for each record and doesn’t change. E.g. a book ISBN.
11
Surrogate Key A surrogate key is a column that is created to hold records of primary key identifier. – It has no real relationship with the row assigned to but rather identify the row uniquely.
12
Foreign Key It is the column in a table that is a primary key of another table. – The foreign key creates a relationship between two independent tables.
13
Composite Key It is a unique key by combining two or more columns of the same table. It usually comprises fields that are primary keys in other tables.
14
Entity Relationship (ER Model) ER model is a design which identify what entities are needed to be include in a database. – It is composed of squares or rectangles which represent entities and lines which represent the relationship between the entities. – There are 3 basic ER model which are One to One relationship One to Many relationship Many to Many relationship
15
One to One Relationship It is when each occurrence of a specific entity, called an instance is found only once in each data set. – E.g. Relationship between birth certificates and a student. – Student ID number and a student. One to One Relationship Student Birth Certificate
16
One to Many Relationship It is when an instance can only appear once in one entity, but one or more times in the other entity. – E.g. a book publisher may publish many books but each book sold has only one publisher. – A U.S president and 50 different States. One to Many Relationship US President 50 States
17
Many to Many Relationship It is when an instance occurs multiple times in each entity – E.g. A student class schedule and how many students are in each class. This is very important aspect to a database designer. Many to Many Relationship StudentCourse
18
SQL and SQL Commands High level query languages are used to interact with relational database. – Query languages contains standard English language such as Insert Create Delete Update Alter These are called Structured Query Language or SQL
19
More SQL SQL consist of about 30 commands that enable users to create database objects and manipulate and view data. SQL falls into 2 different categories – Data Definition language(DDL), which use commands like create and Alter tables – Data Manipulation Language(DML), which uses commands like insert, update, delete, and view database data.
20
Data Types and SQL There are several data types in database which some includes – Character Data Types Varchar2, Char, Nvarchar2, Nchar. – Number Data Types Stores: Negative, Positive, Fixed, and Floating-point numbers.
21
Introduction to Oracle Oracle is an Object Relational Database Management System(ORDBMS). It offers capabilities of both relational and object- oriented database systems. In 242, we focus on relational database perspective! Oracle’s database uses SQL. 21
22
22 Oracle Basics Oracle 10g server is used to maintain and store large amount of data. Client software can have access to the data via server remotely. You must have an existing database instance before you can create an oracle relation (table). If you use Oracle account, you are already given a database instance when DBA opens the account for you.
23
23 Tools of Oracle The tools provided by Oracle are so user friendly that a person with minimum skills in the field of computers can access them with ease. The main tools are: – SQL *Plus – PL/SQL – Forms – Reports
24
24 Introduction to SQL SQL was invented and developed by IBM in early 1970’s. SQL stands for Structured Query Language, which is used for to declare how information should be stored and retrieved from RDBMS. A table (relation) is a primary database object of SQL that is used to store data.
25
25 Introduction to SQL(Cont’d) In order to communicate with the database, SQL supports the following categories of commands:- Data Definition Language- create, alter,drop commands. Data Manipulation Language- insert, select, delete and update commands. Transaction Control Language- commit, savepoint and rollback commands. Data Control Language- grant and revoke commands.
26
26 Benefits of SQL Non-procedural language, because more than one record can be accessed rather than one record at a time. It is common language for all relational databases. In other words it is portable and it requires very few modifications so that it can work on other databases. Very simple commands for querying, inserting and modifying data and objects.
27
27 Oracle Internal Datatypes Character datatypes: - char datatype - varchar2 datatype - Long datatype Number datatype Date datatype Raw datatype Long raw datatype LOB datatype
28
28 Data Definition Language Create tables SQL> CREATE TABLE (,,.... CONSTRAINT pk_name PRIMARY KEY (column_name); CONSTRAINT fk_name FOREIGN KEY (column_name)); REFERENCE name1(name2) ON DELETE CASCADE); Alter the existing table SQL> ALTER TABLE MODIFY/ADD (column definition);
29
29 Data Definition Language(Cont’d) When there is no further use of records in a table and the structure has to be retained, then the records alone can be deleted. SQL>TRUNCATE table ; Drop a table SQL>DROP ;
30
30 Data manipulation Language Insert a tuple into a table SQL>INSERT VALUES ( value_1, value_2, value_3..); Request for information stored in a table SQL> SELECT column_names FROM table_name; Change the existing records in the table SQL>UPDATE SET =value,….. WHERE condition; Delete the rows in the table SQL>DELETE FROM WHERE condition;
31
31 Transaction Control Language Transaction Changes can be made permanent to a database only by committing. Commit command is used to end a transaction and make the changes permanent. SQL>COMMIT; Savepoints are like markers to divide a very lengthy transaction to smaller ones. SQL> SAVEPOINT savepoint_id;
32
32 Transaction Control Language(Cont’d) Rollback command is used to undo the work done in the current transaction. SQL> ROLLBACK ; SQL> ROLLBACK TO SAVEPOINT savepoint_id;
33
33 Data Control language Grant privilege command: Object privileges can be granted to others using the SQL command GRANT SQL>GRANT privileges on to ; To withdraw the privilege that has been granted to a user, we use REVOKE command. SQL>REVOKE privileges on from ;
34
34 SQL*Plus SQL*Plus is an Oracle specific program which accepts SQL commands and PL/SQL blocks and executes them. SQL*Plus enables manipulation of SQL commands and PL/SQL blocks. It performs many additional tasks as well.
35
DBA The person responsible for installing, administering and maintaining database data is called Database Administrator or DBA.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.