Database Basics I101 Summer 2006 Copyright 2004, Matt Hottell.

Slides:



Advertisements
Similar presentations
CIT 613: Relational Database Development using SQL Revision of Tables and Data Types.
Advertisements

Copyright © by Royal Institute of Information Technology Introduction To Structured Query Language (SQL) 1.
SQL’s Data Definition Language (DDL) n DDL statements define, modify and remove objects from data dictionary tables maintained by the DBMS n Whenever you.
Fall 2001Arthur Keller – CS 1808–1 Schedule Today Oct. 18 (TH) Schemas, Views. u Read Sections u Project Part 3 extended to Oct. 23 (T). Oct.
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
Winter 2002Arthur Keller – CS 1808–1 Schedule Today: Jan. 29 (T) u Modifications, Schemas, Views. u Read Sections Assignment 3 due. Jan. 31 (TH)
1 Chapter 2: Creating and Modifying Database Tables.
Using Relational Databases and SQL
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
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.
SQL SQL stands for Structured Query Language SQL allows you to access a database SQL is an ANSI standard computer language SQL can execute queries against.
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”
Database Management System LICT 3011 Eyad H. Elshami.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 10: Data Definition Language.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Oracle Data Definition Language (DDL)
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Database Design lecture 3_1 1 Database Design Lecture 3_1 Data definition in SQL.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
CSC 2720 Building Web Applications Database and SQL.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
1 SQL Tarek El-Shishtawy Professor Ass. Of Computer Engineering.
SQL FUNDAMENTALS SQL ( Structured Query Language )
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
1 Creating and Modifying Database Objects. 2 An Oracle database consists of multiple user accounts Each user account owns database objects Tables Views.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
SCUHolliday - coen 1788–1 Schedule Today u Modifications, Schemas, Views. u Read Sections (except and 6.6.6) Next u Constraints. u Read.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
Tables and Constraints Oracle PL/SQL. Datatypes The SQL Data Definition Language Commands (or DDL) enable us to create, modify and remove database data.
CREATE TABLE CREATE TABLE statement is used for creating relations Each column is described with three parts: column name, data type, and optional constraints.
Prince Sultan University Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Session 11 Creating Tables and Using Data Types. RDBMS and Data Management/Session 11/2 of 40 Session Objectives Define the data types and list the categories.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Visual Programing SQL Overview Section 1.
Lecture5: SQL Overview, Oracle Data Type, DDL and Constraints Ref. Chapter6 Lecture4 1.
1 Chapter 2: Creating and Modifying Database Objects.
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
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.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
Lecture # 24 Introduction to SQL Muhammad Emran Database Systems.
8 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
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.
Creating and Managing Tables. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically represents subsets.
Web Systems & Technologies
Fundamental of Database Systems
Chapter 5 Introduction to SQL.
Insert, Update and the rest…
MIS2502: Data Analytics SQL – Putting Information Into a Database
ORACLE SQL Developer & SQLPLUS Statements
SQL 101.
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
Defining a Database Schema
MIS2502: Data Analytics SQL – Putting Information Into a Database
Oracle Data Definition Language (DDL)
Chapter 2: Creating And Modifying Database Tables
SQL (Structured Query Language)
Presentation transcript:

Database Basics I101 Summer 2006 Copyright 2004, Matt Hottell

Relational Model The relational model is the dominant model for database design today. The relational model was conceived by E.F. Codd of IBM in The relational model is based on set theory and is composed of relations (also known as tables).

Relations Relations are composed of two main elements: Attributes Metadata Tuples The data itself

Attributes Attributes are the column headings in a relational table. They describe the data that is contained in each column Order of attributes is unimportant All of the attributes together make up the schema of the relation.

Tuples Tuples are the complete rows of data in the table. They are also known as records. No two tuples can be exactly the same The order of tuples is not important

Relation Example NameAddressPhone Matt420 Baker Street Jenny12 Tutone Ave Sean1600 N Penn Dr

Relation Example NameAddressPhone Matt420 Baker Street Jenny12 Tutone Ave Sean1600 N Penn Dr Attributes

Relation Example NameAddressPhone Matt420 Baker Street Jenny12 Tutone Ave Sean1600 N Penn Dr Attributes Tuples

Relation Example NameAddressPhone Matt420 Baker Street Jenny12 Tutone Ave Sean1600 N Penn Dr Attributes Tuples Schema

Keys Relational tables often have an attribute or set of attributes that uniquely identifies each tuple. These attributes or sets of attributes are called primary keys.

Example NameAddressPhone Matt420 Baker Street Jenny12 Tutone Ave Sean1600 N Penn Dr

Primary Key Example ID#NameAddressPhone 500Matt420 Baker Street Jenny12 Tutone Ave Sean1600 N Penn Dr

Foreign Keys Foreign keys are attributes in a relational table that refer to a primary key in another relational table. Foreign keys allow us to link relational tables together and gather information based on the contents of multiple tables.

Foreign Key Example ID#NameAddressPhone 500Matt420 Baker Street Jenny12 Tutone Ave Sean1600 N Penn Dr BookIDTitlePrice 1001The Code Book Core Web Programming The Hacker Ethic19.95 ID#BookIDDate /13/ /17/ /26/ /01/03 Book Cust Trans

SQL SQL stands for Structured Query Language. All Relational Database Management Systems use SQL to interact with data. SQL is often implementation-specific MySQL uses different syntax than Oracle We will be using MySQL syntax

Creating a table in SQL The syntax for creating a table is: CREATE TABLE tablename (column1name datatype(size) [constraints], column2name datatype(size) [constraints], column3name datatype(size) [constraints]);

Data Types - Character VARCHAR(maxsize) variable length character data with a maximum size of maxsize. CHAR(fixedsize) fixed-length character data of size fixedsize.

Data Types - Numbers INT or INTEGER Allocates 4 bytes to store numbers NUMERIC(precision, scale) allocates precision number of digits with scale decimal places.

Data Types - Dates DATE Stores year, month, day. TIME Stores hour, minute, second TIMESTAMP(precision) stores year, month, day, hour, minute, and second.

Constraints PRIMARY KEY Indicates that this attribute is the primary key for the table NOT NULL Indicates that this attribute cannot have a null value REFERENCES table(attribute) Declares that this attribute is a foreign key.

Viewing Relational Tables SHOW TABLES; Displays a list of all the available tables in the database. DESCRIBE table_name; Displays the schema of the table.

Adding data You can add data to a table using the following syntax: INSERT INTO table_name (attributes) VALUES (values); Character data must be inside single quotes!

Updating Data Update the value of a particular attribute for a tuple: UPDATE table_name SET column_name = new_value WHERE condition to select row to update

Modifying a table Change an attribute’s datatype ALTER TABLE table_name MODIFY column_name datatype [NULL| NOT NULL]; Add an attribute to a table ALTER TABLE table_name ADD column_name datatype [NULL | NOT NULL]; Delete an attribute from a table ALTER TABLE table_name DROP COLUMN column_name;

Deleting a table DROP TABLE tablename;