+ All Categories
Home > Data & Analytics > Introduction to database & sql

Introduction to database & sql

Date post: 12-Apr-2017
Category:
Upload: zahid6
View: 146 times
Download: 0 times
Share this document with a friend
33
WELCOME TO OUR PRESENTATION INTRODUCTION TO DATABASE & SQL 1
Transcript
Page 1: Introduction to database & sql

1

WELCOME TO OUR PRESENTATION

INTRODUCTION TO DATABASE & SQL

Page 2: Introduction to database & sql

2

What is a Database? Database is a collection of related data,

that contains information relevant to an enterprise.

For example:1. University database2. Employee database3. Student database4. Airlines database

etc…..

Page 3: Introduction to database & sql

3

PROPERTIES OF A DATABASE

A database represents some aspect of the real world, sometimes called the miniworld or the universe of discourse (UoD).

A database is a logically coherent collection of data with some inherent meaning.

A database is designed, built and populated with data for a specific purpose.

Page 4: Introduction to database & sql

4

What is Database Management System (DBMS)?

A database management system (DBMS) is a collection of programs that enables users to create & maintain a database. It facilitates the definition, creation and manipulation of the database.

Definition – it holds only structure of database, not the data. It involves specifying the data types, structures & constraints for the data to be stored in the database.

Creation –it is the inputting of actual data in the database. It involves storing the data itself on some storage medium that is controlled by the DBMS.

Manipulation-it includes functions such as updation, insertion, deletion, retrieval of specific data and generating reports from the data.

Page 5: Introduction to database & sql

5

A SIMPLIFIED DATABASE SYSTEM ENVIRONMENT

5

Page 6: Introduction to database & sql

6

Typical DBMS Functionality Define a database : in terms of data

types, structures and constraints Construct or Load the Database on a

secondary storage medium Manipulating the database : querying,

generating reports, insertions, deletions and modifications to its content

Concurrent Processing and Sharing by a set of users and programs – yet, keeping all data valid and consistent

Page 7: Introduction to database & sql

7

Typical DBMS FunctionalityOther features:

Protection or Security measures to prevent unauthorized access

“Active” processing to take internal actions on data

Presentation and Visualization of data

Page 8: Introduction to database & sql

8

Database System

The database and the DBMS together is called the database system.

Database systems are designed to manage large bodies of information.

It involves both defining structures for storage of information & providing mechanisms for the manipulation of information.

Database system must ensure the safety of the information stored.

Page 9: Introduction to database & sql

9

Database System Applications

Banking- for customer information, accounts & loans, and banking transactions.

Airlines-for reservations & schedule information. Universities-for student information, course registration and

grades. Credit card transactions-for purchases on credit cards &

generation of monthly statements. Telecommunication-for keeping records of calls made,

generating monthly bills, maintaining balances, information about communication networks.

Finance-for storing information about holdings, sales & purchases of financial instruments such as stocks & bonds.

Sales-for customer, product and purchase information. Manufacturing-for management of supply chain & for tracking

production of items in factories. Human resources-for information about employees, salaries,

payroll taxes and benefits

Page 10: Introduction to database & sql

10

Functions of Database administrators (DBA) Coordinating & monitoring the database Authorizing access to the database For acquiring hardware & software

resources as needed by the user Concurrency control checking Security of the database Making backups & recovery Modification of the database structure &

its relation to the physical database

Page 11: Introduction to database & sql

11

Advantages of DBMS Controlling Redundancy Restricting Unauthorized Access Providing Storage Structures for Efficient Query

Processing Providing Backup and Recovery Providing Multiple User Interfaces Representing Complex Relationship among

Data Enforcing Integrity Constraints Permitting Inferencing and Actions using Rules

Page 12: Introduction to database & sql

12

Disadvantages of DBMS Cost of Hardware & Software  Cost of Data Conversion Cost of Staff Training Appointing Technical Staff Database Damage

Page 13: Introduction to database & sql

Different parts of a database Fields Records Queries Reports

Page 14: Introduction to database & sql

Fields

Database storage units Generic elements of content

Page 15: Introduction to database & sql

RecordsA simple table showing fields (columns) and records(rows):

And as part of an MS Access database table:

Page 16: Introduction to database & sql

Queries Queries are the information

retrieval requests you make to the database

Your queries are all about the information you are trying to gather

Page 17: Introduction to database & sql

Reports If the query is a question... ...then the report is its answer Reports can be tailored to the needs

of the data-user, making the information they extract much more useful

Page 18: Introduction to database & sql

18

SQL

Page 19: Introduction to database & sql

19SQL is used for:

Data Manipulation Data Definition Data Administration All are expressed as an SQL statement

or command.

SQL

Page 20: Introduction to database & sql

20Using SQL

To begin, you must first CREATE a database using the following SQL statement:CREATE DATABASE database_nameDepending on the version of SQL being used the following statement is needed to begin using the database:USE database_name

Page 21: Introduction to database & sql

21Using SQL

To create a table in the current database, use the CREATE TABLE keywordCREATE TABLE authors

(auth_id int(9) not null,auth_name char(40) not null)

auth_id auth_name

(9 digit int) (40 char string)

Page 22: Introduction to database & sql

22Table Design

Rows describe the Occurrence of an Entity

SQL

Name Address

Jane Doe 123 Main Street

John Smith 456 Second Street

Mary Poe 789 Third Ave

Columns describe one characteristic of the

entity

Page 23: Introduction to database & sql

23Using SQL

To insert data in the current table, use the keyword INSERT INTO

auth_id auth_name

Then issue the statement

SELECT * FROM authors

INSERT INTO authorsvalues(‘000000001’, ‘John Smith’)

000000001

John Smith

Page 24: Introduction to database & sql

24

Data Retrieval (Queries)

Queries search the database, fetch info, and display it. This is done using the keyword

SELECT * FROM publisherspub_id pub_name address state

0736 New Age Books 1 1st Street MA

0987 Binnet & Hardley 2 2nd Street DC

1120 Algodata Infosys 3 3rd Street CA

The * Operator asks for every column in the table.

Page 25: Introduction to database & sql

25

Data Input Putting data into a table is

accomplished using the keyword

pub_id pub_name address state

0736 New Age Books 1 1st Street MA

0987 Binnet & Hardley 2 2nd Street DC

1120 Algodata Infosys 3 3rd Street CA

Table is updated with new information

INSERT INTO publishersVALUES (‘0010’, ‘pragmatics’, ‘4 4th Ln’, ‘chicago’, ‘il’)

pub_id pub_name address state

0010 Pragmatics 4 4th Ln IL

0736 New Age Books 1 1st Street MA

0987 Binnet & Hardley 2 2nd Street DC

1120 Algodata Infosys 3 3rd Street CA

Page 26: Introduction to database & sql

26

Data Retrieval (Queries)

Queries can be more specific with a few more lines

pub_id pub_name address state

0736 New Age Books 1 1st Street MA

0987 Binnet & Hardley 2 2nd Street DC

1120 Algodata Infosys 3 3rd Street CA

Only publishers in CA are displayed

SELECT *from publisherswhere state = ‘CA’

Page 27: Introduction to database & sql

27Using SQL

SELECT auth_name, auth_cityFROM publishers

auth_id auth_name auth_city auth_state

123456789 Jane Doe Dearborn MI000000001 John Smith Taylor MI

auth_name auth_city

Jane Doe DearbornJohn Smith Taylor

If you only want to display the author’s name and city from the following table:

Page 28: Introduction to database & sql

28Using SQL

DELETE from authorsWHERE auth_name=‘John Smith’

auth_id auth_name auth_city auth_state

123456789 Jane Doe Dearborn MI000000001 John Smith Taylor MI

To delete data from a table, use the DELETE statement:

Page 29: Introduction to database & sql

29Using SQL

UPDATE authorsSET auth_name=‘hello’

auth_id auth_name auth_city auth_state

123456789 Jane Doe Dearborn MI000000001 John Smith Taylor MI

To Update information in a database use the UPDATE keyword

HelloHello

Sets all auth_name fields to hello

Page 30: Introduction to database & sql

30Using SQL

ALTER TABLE authorsADD birth_date datetime null

auth_id auth_name auth_city auth_state

123456789 Jane Doe Dearborn MI000000001 John Smith Taylor MI

To change a table in a database use ALTER TABLE. ADD adds a characteristic.

ADD puts a new column in the table called birth_date

birth_date

.

.

Type Initializer

Page 31: Introduction to database & sql

31Using SQL

ALTER TABLE authorsDROP birth_date

auth_id auth_name auth_city auth_state

123456789 Jane Doe Dearborn MI000000001 John Smith Taylor MI

To delete a column or row, use the keyword DROP

DROP removed the birth_date characteristic from the table

auth_state

.

.

Page 32: Introduction to database & sql

32Using SQL

DROP DATABASE authors

auth_id auth_name auth_city auth_state

123456789 Jane Doe Dearborn MI000000001 John Smith Taylor MI

The DROP statement is also used to delete an entire database.

DROP removed the database and returned the memory to system

Page 33: Introduction to database & sql

33


Recommended