Top Banner
Er. Nawaraj Bhandari Database
28
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Database

Er. Nawaraj Bhandari

Database

Page 2: Database

Module Database : Exam Pattern

Global Exam : 50%

Global Assignment : 50%

Page 3: Database

Module Database : Software

MySQL

Oracle

SQL Server

Access

Page 4: Database

What is a database?

“A database is a computerised record keeping system”

Page 5: Database

Record Keeping Systems

File system on a computer Word document Excel Spreadsheet Access database Manual card index file Files on a USB stick Are these all databases?

Page 6: Database

Database Functions

Databases should be able to:

Store Manipulate Retrieve

Page 7: Database

Database Size - 1

Databases range in size:

Single user databases on a PC Small office database with everyone doing the

same sorts of tasks Medium size database system with core data but

people doing different tasks Corporate databases spread over many sites Very large databases and data-warehouses

Page 8: Database

But databases aren’t like buckets!

Database systems are not just a mass of data

It isn’t just about what they can hold

They are organised So we need a more

precise definition

Page 9: Database

More Detailed Definition

“We define a database as an organised collection of logically related data”.

Page 10: Database

What does this mean?

Organised Logically related Data

Page 11: Database

Organised

Data is structured so as to be easily stored, manipulated and retrieved by users.

It is no good just having some data if we don’t know how to get it in order to look at it and use it.

Page 12: Database

Related

Pieces of data do not exist in isolation For example:

In a salesperson’s database, it is natural for the customer’s name and the customer’s address to be stored together

They are related Together, with other data about the customer,

they are part of a meaningful set

Page 13: Database

Data Data are any raw facts, numbers, or text that can be processed by

a computer.

Data can be found in different formats : 1. operational or transactional data such as, sales, cost,

inventory, payroll, and accounting

2. nonoperational data such as forecast data

3. meta data - data about the data itself, such as logical database design or data dictionary definitions

Page 14: Database

Types of Data

1. Traditionala. Text such as names, address etc.b. Numbers such as age, roll number, number of friends, etc.c. Dates such as a date of birth, college enrolled date, exam

date, etc.

2. Multi-mediaa. Imagesb. Soundsc. Video

Page 15: Database

Data and Information

There is a little distinction between ‘data’ and ‘information’

Data are ‘raw facts’.

Bagum, Ammena 01.02.81 97327627Ako, Sarah 08.08.81 98737373Finkle, Clive 09.09.81 93838383Mc Farren, Debra 01.01.80 98383837Sinseros, Douglas 27.05.80 99344222

Page 16: Database

Information

Information is data that has been processed in such a way that it can increase the knowledge of the person who uses it.

Student Name Date of Birth Student IDBagum, Ammena 01.02.81 97327627Ako, Sarah 08.08.81 98737373Finkle, Clive 09.09.81 93838383Mc Farren, Debra 01.01.80 98383837Sinseros, Douglas 27.05.80 99344222

Page 17: Database

Information is Important

Economically

Politically

Personally

Databases are the key to information.

Page 18: Database

SQL

Structured Query Language

Page 19: Database

SQL is a Standard

SQL(Structural Query Language) is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems.

SQL statements are used to retrieve and update data in a database.

SQL works with database programs like MS Access, DB2, Informix, MS SQL Server, Oracle, Sybase, etc.

Page 20: Database

SQL Database Tables

A database most often contains one or more tables. Each table is identified by a name (e.g. “Workers" or “Departments"). Tables contain records (rows) with data.

Below is an example of a table called “Workers":

LastName FirstName Jobtitle Age

Surani Lawrence Manager 56

Argo Emily 32

Villa Ahmed Packer 25

Manager

Page 21: Database

With SQL, we can query a database and have a result set returned.

A query like this:

SELECT LastName FROM workers

Gives a result set like this:

SQL Queries

LastName

Surani

Argo

Villa

Page 22: Database

Select all record from workers tables

SELECT * FROM workers

SQL Queries

Page 23: Database

• Data Definition Language(DDL)• Data Manipulation Language (DML) • Data Control Language (DCL) • Transaction Control (TCL)

SQL COMMANDS

Page 24: Database

DDL statements are used to define the database structure or schema

Data Definition Language(DDL)

• CREATE: to create objects in the database• ALTER: updates the structure of the database• DROP - delete objects from the database• TRUNCATE - remove all records from a table,

including all spaces allocated for the records are removed

• COMMENT - add comments to the data dictionary

Page 25: Database

DML statements are used for managing data within schema objects.

Data Manipulation Language (DML)

• SELECT - retrieve data from the a database• INSERT - insert data into a table• UPDATE - updates existing data within a table• DELETE - deletes all records from a table, the space

for the records remain• MERGE - UPSERT operation (insert or update)• CALL - call a PL/SQL or Java subprogram• EXPLAIN PLAN - explain access path to data• LOCK TABLE - control concurrency

Page 26: Database

Data Control Language (DCL)

• GRANT - gives user's access privileges to database

• REVOKE - withdraw access privileges given with the GRANT command

Page 27: Database

TCL statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.

Transaction Control Language (TCL)

• COMMIT - save work done• ROLLBACK - restore database to original since the last

COMMIT• SAVEPOINT - identify a point in a transaction to which

you can later roll back• SET TRANSACTION - Change transaction options like

isolation level and what rollback segment to use

Page 28: Database

ANY QUESTIONS?