SQL OVERVIEW DEFINING A SCHEMA

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

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)
Basic SQL types String –Char(n): fixed length. Padded –Varchar(n): variable length Number –Integer: 32 bit –Decimal(5,2): –Real, Double: 32 bit,
13.5 Representing Data Elements Fields, Records, Blocks Variable-length Data Modifying Records.
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 Overview Defining a Schema CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer.
Database Management System LICT 3011 Eyad H. Elshami.
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.
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.
Chapter 5: Part 1: DDL STRUCTURED QUERY LANGUAGE (SQL)
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
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.
Prince Sultan University Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
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.
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.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
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.
CPSC-310 Database Systems
Chapter 10 SQL DDL.
Fundamental of Database Systems
CS 3630 Database Design and Implementation
Relational Data Model Lu Chaojun, SJTU.
Insert, Update and the rest…
CS 480: Database Systems Lecture 13 February 13,2013.
Database Construction and Usage
Designing Tables for a Database System
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
Database Models Relational Model
DATABASE MANAGEMENT SYSTEM
STRUCTURED QUERY LANGUAGE
Instructor: Mohamed Eltabakh
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
Lecture 14: SQL Wednesday, October 31, 2001.
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 CSCE 315 – Programming Studio Spring 201 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 1st generation Machine code 2nd generation Human-readable but directly related to processor Assembly language, C (sort of) 3rd generation Abstraction from processor, easier for humans Fortran, C/C++, Java, etc. 4th generation Programming Language for specific task e.g. SQL, Matlab 5th 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 Query Language Supports query operations (does not change data itself) Others Transaction control, Data control (access permissions)

Our Discussion of SQL Will highlight some of the structures and features of SQL Give you an idea of the basics of how SQL 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 <name> ( <element list> ); element = <name> <type>

Element Types INT, INTEGER FLOAT, REAL CHAR(n) VARCHAR(n) DATE TIME 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 120000.00 );

Other Table Modifications DROP <name> Deletes that table ALTER TABLE <name> ADD <attribute> Adds a new column to table ALTER TABLE <name> DROP <attribute> 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 <name> AS <query>