SQL Overview Defining a Schema CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer.

Slides:



Advertisements
Similar presentations
Fall 2005 ICS184/EECS116 – Notes 08 1 ICS 184/EECS116: Introduction to Data Management Lecture Note 8 SQL: Structured Query Language -- DDL.
Advertisements

Overview Begin 6:00 Quiz15 mins6:15 Review Table Terms25 mins6:40 Short Break10 mins6:50 SQL: Creating Tables60 mins7:50 Break10 mins8:00 Lab – Creating.
Database Design -- Basic SQL
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.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 28 Database Systems I The Relational Data Model.
SQL Sangeeta Devadiga CS157A, Fall Outline Background Data Definition Basic Structure Set Operation.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 SQL: Data Definition, Constraints, and Basic Queries and Updates.
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.
Winter 2002Arthur Keller – CS 1808–1 Schedule Today: Jan. 29 (T) u Modifications, Schemas, Views. u Read Sections Assignment 3 due. Jan. 31 (TH)
13.5 Representing Data Elements Fields, Records, Blocks Variable-length Data Modifying Records.
Database Modifications A modification command does not return a result as a query does, but it changes the database in some way. There are three kinds.
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.
Chapter 12 Representing Data Elements By Yue Lu CS257 Spring 2008 Instructor: Dr.Lin.
Database Management System LICT 3011 Eyad H. Elshami.
1 Relational Data Model CS 157B Nidhi Patel. 2 What is a Data Model? A notation for describing data or information A notation for describing data or information.
Database Systems Lecture 5 Natasha Alechina
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.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch Via Yoonsuck Choe.
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
CSE314 Database Systems Lecture 4 Basic SQL Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
CSCE 520- Relational Data Model Lecture 2. Relational Data Model The following slides are reused by the permission of the author, J. Ullman, from the.
1 The Relational Model Instructor: Mohamed Eltabakh
Chapter 8 Part 1 SQL-99 Schema Definition, Constraints, Queries, and Views.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
Winter 2006Keller Ullman Cushing8–1 Turning in Assignments Please turn in hard copy (use only in the direst of circumstances). I am not your secretary.
CSC 2720 Building Web Applications Database and SQL.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
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.
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.
Advanced Database CS-426 Week 1 - Introduction. Database Management System DBMS contains information about a particular enterprise Collection of interrelated.
Dec 8, 2003Murali Mani Constraints B term 2004: lecture 15.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Prince Sultan University Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
1 Database Systems Defining Database Schema Views.
Lu Chaojun, SJTU Relational Data Model 1. Lu Chaojun, SJTU What’s a Data Model? A notation (collection of conceptual tools) for describing data as seen.
CS 338The Relational Model2-1 The Relational Model Lecture Topics Overview of SQL Underlying relational model Relational database structure SQL DDL and.
CSCE 520- Relational Data Model Lecture 2. Oracle login Login from the linux lab or ssh to one of the linux servers using your cse username and password.
1 CSCE Database Systems Anxiao (Andrew) Jiang The Database Language SQL.
CMPT 258 Database Systems The Relationship Model (Chapter 3)
Week 8-9 SQL-1. SQL Components: DDL, DCL, & DML SQL is a very large and powerful language, but every type of SQL statement falls within one of three main.
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
1 CS 430 Database Theory Winter 2005 Lecture 11: SQL DDL.
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Databases : SQL-Schema Definition and View 2007, Fall Pusan National University Ki-Joune Li These slides are made from the materials that Prof. Jeffrey.
The Relational Model of Data Prof. Yin-Fu Huang CSIE, NYUST Chapter 2.
SQL Overview CPSC 315 – Programming Studio Spring 2013 Project 1, Part 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch.
Lecture # 24 Introduction to SQL Muhammad Emran Database Systems.
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
Understand Data Definition Language (DDL) Database Administration Fundamentals LESSON 1.4.
1 Designing Tables for a Database System. 2 Where we were, and where we’re going The Entity-Relationship model: Used to model the world The Relational.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
CPSC-310 Database Systems
Insert, Update and the rest…
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
Database Models Relational Model
SQL OVERVIEW DEFINING A SCHEMA
Defining a Database Schema
CMPT 354: Database System I
SQL-1 Week 8-9.
Session - 6 Sequence - 1 SQL: The Structured Query Language:
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Instructor: SAMIA ARSHAD
CMSC-461 Database Management Systems
CPSC 315 – Programming Studio Spring 2017 Project 1, Part 3
CSCE 315, Spring 2019 Project 1, Part 3 Robert Lightfoot
SQL (Structured Query Language)
Presentation transcript:

SQL Overview Defining a Schema CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch

SQL Structured Query Language Database language used to manage and query relational databases A well-known, commonly used standard Regularly updated Many extensions, variations Platform-specific versions, etc.

Generations of Programming Languages 1 st generation Machine code 2 nd generation Human-readable but directly related to processor Assembly language, C (sort of) 3 rd generation Abstraction from processor, easier for humans Fortran, C/C++, Java, etc. 4 th generation Programming Language for specific task e.g. SQL, Matlab 5 th generation Give constraints (goal), and result follows logically e.g. Prolog

SQL Elements Data Definition Language (DDL) Supports creation of database schema Data Manipulation Language (DML) Supports entering/removing data Querying Language Supports query operations (don’t change data itself) Others: Transaction control, Data control

Our Discussion of SQL Will highlight some of the structures and features of SQL Give you an idea of the basics of how it works Reflects how relational databases work Not meant to make you SQL programmers You will need to implement equivalent functions for parts of what we discuss

Database Schema The set of relations (tables) in the database. Create, delete, change tables

CREATE Define a relation CREATE TABLE ( ); element =

Element Types INT, INTEGER Integers FLOAT, REAL Floating-Point numbers CHAR(n) Fixed-length string of n characters VARCHAR(n) Variable-length string of up to n characters DATE yyyy-mm-dd TIME hh:mm:ss

Example CREATE TABLE HouseRep ( Name VARCHAR(80), Party CHAR(10), Birthdate DATE, YearsInCongress INT, Salary REAL );

Declaring Keys Keys declared within CREATE statement Key attributes functionally determine all other attributes in the relation List under PRIMARY KEY Elements of primary key can not be NULL

Example CREATE TABLE HouseRep ( Name VARCHAR(80), Party CHAR(10), Birthdate DATE, YearsInCongress INT, Salary REAL, PRIMARY KEY (Name) );

Example CREATE TABLE HouseRep ( Name VARCHAR(80), Party CHAR(10), Birthdate DATE, YearsInCongress INT, Salary REAL, PRIMARY KEY (Name, Birthdate) );

Other Element Modifiers UNIQUE Placed after type Only one tuple in that relation for each value (except NULL) Can imply key if no primary key given Can be NULL NOT NULL Cannot take value NULL DEFAULT Default value specified

Example CREATE TABLE HouseRep ( Name VARCHAR(80) UNIQUE, Party CHAR(10), Birthdate DATE NOT NULL, YearsInCongress INT DEFAULT 0, Salary REAL DEFAULT );

Other Table Modifications DROP Deletes that table ALTER TABLE ADD Adds a new column to table ALTER TABLE DROP Removes the column from the table

Views Views are a sort of “virtual table”, usually created as the result of a query We’ll discuss queries later Format: CREATE VIEW AS