Overview Relational Databases and SQL Pertemuan 1 Matakuliah: T0413/Current Popular IT II Tahun: 2007.

Slides:



Advertisements
Similar presentations
Basic SQL Introduction Presented by: Madhuri Bhogadi.
Advertisements

Introduction to Structured Query Language (SQL)
Sanjay Goel, School of Business, University at Albany, SUNY 1 SQL- Data Definition Language ITM 692 Sanjay Goel.
Maintaining Referential Integrity Pertemuan 2 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 11.
VIEWS Pertemuan 7 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
Introduction to Structured Query Language (SQL)
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
Fundamentals, Design, and Implementation, 9/e Chapter 6 Introduction to Structured Query Language (SQL)
Security and Transaction Management Pertemuan 8 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
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.
Introduction to Structured Query Language (SQL)
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Oracle Data Definition Language (DDL)
1 IT420: Database Management and Organization SQL: Structured Query Language 25 January 2006 Adina Crăiniceanu
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
ASP.NET Programming with C# and SQL Server First 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 Technical Session By: Prof. Adarsh Patel.
Data Modeling and Database Design
Chapter 10 – Database Creation1 IT238: Data Modeling and Database Design Unit 6: Database Creation Instructor: Qing Yan, M.D., Ph.D.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
Chapter 5: Part 1: DDL STRUCTURED QUERY LANGUAGE (SQL)
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 6/1 Copyright © 2004 Please……. No Food Or Drink in the class.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 7 Introduction to Structured.
SQL Unit – 2 Base Knowledge Presented By Mr. R.Aravindhan.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Oracle 11g: SQL Chapter 4 Constraints.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Visual Programing SQL Overview Section 1.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
1 DBS201: More on SQL Lecture 3. 2 Agenda How to use SQL to update table definitions How to update data in a table How to join tables together.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
Populating and Querying tables Insert, Update, Delete and View (DML)
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
11-1 © Prentice Hall, 2004 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Basic SQL تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة.
SQL Basics Review Reviewing what we’ve learned so far…….
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
Retrieving Information Pertemuan 3 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
In this session, you will learn to: Manage databases Manage tables Objectives.
Fundamentals of DBMS Notes-1.
Managing Tables, Data Integrity, Constraints by Adrienne Watt
SQL: Schema Definition and Constraints Chapter 6 week 6
Oracle & SQL Introduction
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.
لغة قواعد البيانات STRUCTURED QUERY LANGUAGE SQL))
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
Oracle Data Definition Language (DDL)
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Presentation transcript:

Overview Relational Databases and SQL Pertemuan 1 Matakuliah: T0413/Current Popular IT II Tahun: 2007

2 AGENDA: Review Relational Databases Overview SQL Creating a Database Creating, Changing, and Dropping Tables Book: Mastering SQL by Martin Gruber Sybex (2000) Chapter : 1 - 3

3 Review Relational Databases What is a Relational Database? – It is a body of persistent information stored in two-dimensional tables (by a computer program), where the data survives the terminations of a program or user session that created it. A simple way to picture a relational database is to think of an address book. Suppose you were to format this address book as a tables with rows and columns, each row would corresponds to a certain individual.

4 Review Relational Databases (cont’d) However, what if there were more than one individual named Celia Brock? Or Gerry Farish ? You should assign each person a unique identifier ( a value that is different for each person) It is called Primary Key Table with Primary Key added  Client Table :

5 The need of Second Table Suppose we need to add a telephone number column to Client table. Most people have more than one telephone number (fax, cell phone, etc). Solution : build another table Client_Phone table : Client_Phone table also contains Primary Key from Client table The ID_Num in Client_Phone table is called Foreign Key, because it references the Primary Key in Client table

6 The need of Second Table (cont’d) If all the Foreign Keys values in Client_Phone table reference values that are actually present in Client table, the system has Referential Integrity. We also need a Primary Key for the Client_Phone table. A Primary or Foreign Key need not be a single column. We can combine the ID_Num and Phone columns as the Primary Keys for Client_Phone table. As long as the combination of both columns are always unique. A key of more than one column is referred by : – Multicolumn Key, or – Composite Key, or – Concatenated Key.

7 Joining Tables When we extract the information contained in the two separate tables (Client and Client_Phone), we can link each Foreign Key values that match the values in Primary Key. An operation that extracts information from database is called a query. A query that extracts data from more than one table at the same time by relating columns in one table to columns in the other(s) is called a Join. Queries are implemented in SQL with the SELECT statement.

8 How a Relational Database Fits Together Tables were grouped in a database. It is called Schema ( a group of interrelated tables). A database can contain any number of Schemas. Relational systems allow you to work with the data at a higher level, all operations on the data are handled by a program called DBMS, which responds only to statements expressed in a high-level language. DBMS = Database Management System

9 Overview SQL SQL is a language oriented specifically around relational databases. Forms of SQL: – Interactive SQL – Static SQL – Dynamic SQL The Subdivisions of SQL: – DDL (Data Definition Language) – DML (Data Manipulation Language) – DCL (Data Control Language)

10 Overview SQL (cont’d) Various Types of Data (datatype) can be divided into the following categories: – Text – Numeric – Datetime – Binary, etc Two very important concepts, 1. Predicate : a set of criteria use to decide whether a statement will or will not be executed against a particular row of a table. 2. Query : it is a request for information from the database. In other words, a SELECT statement.

11 Overview SQL (cont’d) Basic SQL Statements: SELECT snum, sname, city, comm FROM Salespeople WHERE sname = ‘Peel’; DELETE FROM Salespeople WHERE snum = 1001;

12 Creating a Database Example : CREATE DATABASE MYDBASE ON PRIMARY (  OPTIONAL : primary filegroup berisi system tables NAME = MYDBASE_DATA, FILENAME =”C:\mssql\data\mydb.mdf”  nama file yang berlaku pada OS, ditulis full pathname SIZE=20MB,  besar awal dari file dengan satuan MB (default) atau KB. MAXSIZE=40mb,  maksimum besar file yang dapat dicapai dalam MB atau KB FILEGROWTH=1MB  pertumbuhan file dalam MB

13 Modifying a Database Example : ALTER DATABASE MYDBASE MODIFY FILE ( NAME = MYDBASE_DATA, SIZE = 60MB );

14 Creating, Changing, and Dropping Tables CREATING TABLES Tables are being defined using CREATE TABLE command It creates an initially empty tables The command defines a table name as describing a set of named columns in a specified order. It also defines the data types and sizes of the columns. Each table must have at least one column. Syntax: CREATE TABLE tablename ({columnname datatype[(size)]},…);

15 Creating, Changing, and Dropping Tables (cont’d) Example: CREATE TABLE Salespeople ( snum INTEGER, sname CHAR(10), city CHAR(10), comm DECIMAL ); Order of columns are determined by the order specified inside the CREATE TABLE command. By using INSERT statement, we can insert values into the table that we have created before.

16 Creating, Changing, and Dropping Tables (cont’d) CHANGING TABLES ALTER TABLE statement is used to change the definitions in a table. ALTER TABLE can do the following: – Add a column to a table – Drop a column from a table – Add a table constraint to a table – Drop a constraint from a table – Add a default value to a column – Drop a default value from a column

17 Creating, Changing, and Dropping Tables (cont’d) Syntax: ALTER TABLE tablename {ADD [COLUMN] column definition } | { ALTER [COLUMN] column name { SET DEFAULT default option } | {DROP DEFAULT } } | { DROP [COLUMN] column name } | { ADD table constraint definition } | { DROP CONSTRAINT constraint name }; Example: – ALTER TABLE Salespeople ADD fname CHAR(10); – ALTER TABLE Salespeople ALTER COLUMN city ADD DEFAULT ‘London’;

18 Creating, Changing, and Dropping Tables (cont’d) DROPPING TABLES Dropping tables is actually a two-steps process: – Empty the table of any data by using the DELETE statement – Destroy the definition of the table by using DROP TABLE statement Syntax: – DROP TABLE tablename [RESTRICT | CASCADE]; The RESTRICT or CASCADE clause refers to what happens when other objects (such as Views) exist that depend on this table. – If RESTRICT is specified then DROP is disallowed. – If CASCADE is specified then dependent objects are automatically dropped as well. In the end, table are no longer recognized in the schema.

19 End of Overview Relational Databases and SQL Thank you