Databases MIS 21. Some database terminology  Database: integrated collection of data  Database Management System (DBMS): environment that provides mechanisms.

Slides:



Advertisements
Similar presentations
The Relational Model. Introduction Introduced by Ted Codd at IBM Research in 1970 The relational model represents data in the form of table. Main concept.
Advertisements

 2003 Prentice Hall, Inc. All rights reserved. Chapter 22 – Database: SQL, MySQL, DBI and ADO.NET Outline 22.1 Introduction 22.2 Relational Database Model.
OUTLINE OF THE LECTURE PART I GOAL: Understand the Data Definition Statements in Fig 4.1 Step1: Columns of the Tables and Data types. Step2: Single column.
Copyright © by Royal Institute of Information Technology Introduction To Structured Query Language (SQL) 1.
Introduction to Structured Query Language (SQL)
CSE 190: Internet E-Commerce Lecture 10: Data Tier.
Structured Query Language Part II Chapter Three CIS 218.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
Structured Query Language Part I Chapter Three CIS 218.
Structured Query Language Chapter Three (Excerpts) DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
Structured Query Language Chapter Three DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
Introduction –All information systems create, read, update and delete data. This data is stored in files and databases. Files are collections of similar.
ASP.NET Programming with C# and SQL Server First Edition
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
CHAPTER 7 Database: SQL, MySQL. Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Database A collection of related data. Database Applications Banking: all transactions Airlines: reservations, schedules Universities: registration, grades.
Introduction to SQL Steve Perry
2440: 141 Web Site Administration Database Management Using SQL Professor: Enoch E. Damson.
SQL Review Tonga Institute of Higher Education. SQL Introduction SQL (Structured Query Language) a language that allows a developer to work with data.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
CHAPTER 8 Database: SQL, MySQL. Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured.
CSC 2720 Building Web Applications Database and SQL.
Database: SQL and MySQL
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Visual Programing SQL Overview Section 1.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
A CCESSING D ATABASES WITH JDBC CH 24 C S 442: A DVANCED J AVA P ROGRAMMING.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 22 - SQL, MySQL, DBI and ADO Outline 22.1 Introduction 22.2 Relational Database Model 22.3 Relational.
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
Chapter 13.3: Databases Invitation to Computer Science, Java Version, Second Edition.
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
WEEK# 12 Haifa Abulaiha November 02,
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
Dr Gordon Russell, Napier University Unit SQL 1 1 SQL 1 Unit 1.2.
Manipulating Data Lesson 3. Objectives Queries The SELECT query to retrieve or extract data from one table, how to retrieve or extract data by using.
Introduction to Database SEM I, AY Department of Information Technology Salalah College of Technology Chapter No.3 SQL.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Simple Queries DBS301 – Week 1. Objectives Basic SELECT statement Computed columns Aliases Concatenation operator Use of DISTINCT to eliminate duplicates.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
Introduction to Database Programming with Python Gary Stewart
Fundamentals of DBMS Notes-1.
CHAPTER 7 DATABASE ACCESS THROUGH WEB
 2012 Pearson Education, Inc. All rights reserved.
Basic select statement
ATS Application Programming: Java Programming
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
Chapter 22 - SQL, MySQL, DBI and ADO
Introduction To Structured Query Language (SQL)
The University of Akron College of Applied Science & Technology Dept
Manipulating Data Lesson 3.
Presentation transcript:

Databases MIS 21

Some database terminology  Database: integrated collection of data  Database Management System (DBMS): environment that provides mechanisms for storage and access of data  Relational Database Model: views a database as a collection of relations or tables where each table stores information on an entity

Tables, attributes and columns  A table represents an entity in a system  The rows of the table represent records or instances of the entity  The columns of the table represent the entity’s attributes or characteristics  How do you determine a system’s entities? Spot the nouns (people, places, things) in the system

Example: The STUDENT table IDLastNameFirstNameYearQPI CruzJuan SmithJohn CruzMaria SantosLinda43.0 Columns/Attributes There are four rows/records in this example

Column types/domains  Each column in a table has an associated type indicating the possible values for the attribute  Most common types Strings: CHAR, VARCHAR Numbers: INTEGER, DOUBLE, NUMERIC Date and time: DATE, TIME, TIMESTAMP

Primary key, foreign key, relationships  Primary key: column or attribute that uniquely determines a row in the table STUDENT table example: ID is the primary key  Foreign key: attribute in one table that refers to a record in another table Used to store relationships (relationships are verbs in the system) Example: a department code in the EMPLOYEE table refers to the DEPARTMENT table, signifying that the employee belongs to the department

Relationship example EmpIDNameSalaryDeptCode 123CRUZ, JUAN HR 222SANTOS, MARIA HR 545MATIPID, PETE ACCT DeptCodeDeptName ACCTACCOUNTING HRPERSONNEL MAINTMAINTENANCE EMPLOYEE DEPARTMENT Employee SANTOS, MARIA works for the PERSONNEL department

Structured Query Language  SQL: Structured Query Language Also called “SeQueL” Standard underlying language for database definition, manipulation, and query  SQL statements SELECT (query) INSERT UPDATE DELETE Others (Data Definition)

The SELECT statement  A query that returns a table  Simplest form: SELECT column1, column2, … FROM table SELECT EmpID, Salary FROM EMPLOYEE  List all records, all columns SELECT * FROM table SELECT * FROM DEPARTMENT  List particular record/s SELECT * FROM table WHERE criteria SELECT * FROM STUDENT WHERE year=3

The WHERE clause  Indicates selection criteria or condition against which records on the table will be checked  Contains operators such as, = =, <> and LIKE <> means not equal LIKE performs a pattern match with strings ( _ matches a single character, % matches several characters) Condition may have logical operators (AND, OR, NOT)  Note the importance of the column type when specifying the condition Literal strings (e.g., CHAR) need to be delimited by quotes or double quotes

ORDER BY clause  Can indicate ORDER BY in the SELECT statement to specify ghe order in which the records will be listed  Syntax: append ORDER BY col1,col2,… to the SELECT statement  Indicate ORDER BY col1,col2,… DESC to list records in descending order

More examples  SELECT Name FROM EMPLOYEE WHERE SALARY >  SELECT FirstName,Lastname FROM STUDENT WHERE LastName LIKE ‘S%’  SELECT * FROM STUDENT WHERE year <> 2  SELECT * FROM STUDENT WHERE year=3 ORDER BY LastName, FirstName  SELECT Name FROM EMPLOYEE ORDER BY Salary

SELECT on multiple tables  FROM clause can contain multiple tables  Use when processing relationships  Tables are joined; indicate join condition in WHERE clause  Example: SELECT Name, DeptName FROM EMPLOYEE, DEPARTMENT WHERE EMPLOYEE.DeptCode = DEPARTMENT.DeptCode AND Salary >10000 returns all names of employees (and the name of the departments they belong to) who make more than 10000

The INSERT Statement  Inserts a record into a table  Syntax: INSERT INTO table VALUES(val1,val2,…) INSERT INTO table(col1,col2,…) VALUES(val1,val2,…)  Examples: INSERT INTO DEPARTMENT VALUES(“CS”, “COMPUTER SCIENCE”) INSERT INTO EMPLOYEE(EmpID, Salary) VALUES(143, )

The UPDATE Statement  Updates an existing record  Syntax: UPDATE table SET col1=expr1,col2=expr2,… UPDATE table SET col1=expr1,col2=expr2,… WHERE criteria  Examples (updates all records) UPDATE EMPLOYEE SET Salary=Salary+100 (updates some record/s) UPDATE STUDENT SET QPI = 4.0 WHERE FirstName = “Matalino”

The DELETE Statement  Deletes records from a table  Syntax: DELETE FROM table WHERE criteria (warning: without a WHERE clause, all records are deleted)  Example DELETE FROM EMPLOYEE WHERE DeptCode=“CS”

Summary  A relational database consists of tables that store records of a system  The database is manipulated through SQL, the underlying query and manipulation language of relational databases  SELECT statements carry out queries  INSERT, UPDATE, and DELETE statements affect the database