Www.hope.ac.uk Deanery of Business & Computer Sciences SQL Structured Query Language Implementation Lecture – 8 Database Technology Level I.

Slides:



Advertisements
Similar presentations
Data Definition and Integrity Constraints
Advertisements

Basic SQL Introduction Presented by: Madhuri Bhogadi.
1 SQL Server Management Studio SQL DDL CREATE TABLE Constraints ALTER TABLE DROP TABLE The GUI way Steen Jensen, autumn 2013.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
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.
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
Design process Identify entities and attributes –What do you want to know? –Note that the question of whether something is an attribute or an entity may.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
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 Keys and Constraints Justin Maksim. Key Declaration Key constraint defined within the CREATE TABLE command Key can be declared using either the PRIMARY.
5 Chapter 5 Structured Query Language (SQL1) Revision.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Data at the Core of the Enterprise. Objectives  Define of database systems  Introduce data modeling and SQL  Discuss emerging requirements of database.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Database Systems Lecture 5 Natasha Alechina
1 IT420: Database Management and Organization SQL: Structured Query Language 25 January 2006 Adina Crăiniceanu
SQL Basics. SQL SQL (Structured Query Language) is a special-purpose programming language designed from managing data in relational database management.
Database Lecture # 1 By Ubaid Ullah.
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
IE 423 – Design of Decision Support Systems Database development – Relationships and Queries Introduction to SQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
RDB/1 An introduction to RDBMS Objectives –To learn about the history and future direction of the SQL standard –To get an overall appreciation of a modern.
SQL Data Definition (CB Chapter 6) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
Database Technical Session By: Prof. Adarsh Patel.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
Deanery of Business & Computer Sciences Transformation of Logical Diagram into Database Design Language Lecture 6 Database Technology Level.
HSCI 709 SQL Data Definition Language. SQL Standard SQL-92 was developed by the INCITS Technical Committee H2 on Databases. SQL-92 was designed to be.
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)
FEN  Data Definition: CREATE TABLE, ALTER TABLE  Data Manipulation: INSERT, UPDATE, DELETE  Queries: SELECT SQL: Structured Query Language.
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.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 7 (Part a): Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Database Management COP4540, SCS, FIU Structured Query Language (Chapter 8)
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.
SQL introduction 2013.
SQL Structured Query Language. Aims  To introduce the implementation of a Physical design using SQL.  To introduce SQL Data Definition Language (DDL).
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
GLOBEX INFOTEK Copyright © 2013 Dr. Emelda Ntinglet-DavisSYSTEMS ANALYSIS AND DESIGN METHODSINTRODUCTORY SESSION EFFECTIVE DATABASE DESIGN for BEGINNERS.
DATA AND SCHEMA MODIFICATIONS CHAPTERS 4,5 (6/E) CHAPTER 8 (5/E) 1.
An Introduction to SQL For CS Overview of SQL  It is the standard language for relational systems, although imperfect  Supports data definition.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
Chapter 3: Relational Databases
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Understand Data Definition Language (DDL) Database Administration Fundamentals LESSON 1.4.
Copyright © Curt Hill SQL The Data Manipulation Language.
CS SQL.
SQL: Schema Definition and Constraints Chapter 6 week 6
Insert, Update and the rest…
STRUCTURED QUERY LANGUAGE
Structured Query Language (Data definition Language)
لغة قواعد البيانات STRUCTURED QUERY LANGUAGE SQL))
مقدمة في قواعد البيانات
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Instructor: Samia arshad
DATABASE Purpose of database
Presentation transcript:

Deanery of Business & Computer Sciences SQL Structured Query Language Implementation Lecture – 8 Database Technology Level I

Deanery of Business & Computer Sciences 2 Aims To introduce the implementation of a Physical design using SQL. To introduce SQL Data Definition Language (DDL). To introduce SQL Data Manipulation Language (DML).

Deanery of Business & Computer Sciences 3 Implementation of a Physical Design Database Design Language Course (courseCode, title, cost) Entity Course is converted to the following physical design. courseCode and title are set to text and indexed appropriately, cost is set to Currency tblCourse Field NameData TypeSizeFormatKey TypeIndexRequired courseCodeText8Primary KeyYes(no duplicates)Yes titleText25Yes costCurrency No

Deanery of Business & Computer Sciences 4 SQL (Data Definition Language - DDL Database Definition Commands CREATE DATABASE DROP DATABASE SHOW DATABASES CREATE TABLE ALTER TABLE

Deanery of Business & Computer Sciences 5 SQL Create Table CREATE TABLE (, ….. );

Deanery of Business & Computer Sciences 6 SQL Create Table Each column definition has 3 components. this the name of the attribute identified in the design. specified for the attribute in the Physical design. The data types available for use will depend on those appropriate for the software with which the database is to be implemented. such as specification of Primary Keys, Indexes and Nulls.

Deanery of Business & Computer Sciences 7 SQL Create Table CREATE TABLE tblCourse (courseCode VARCHAR(8) PRIMARY KEY, title VARCHAR(25) NOT NULL, cost CURRENCY );

Deanery of Business & Computer Sciences 8 Implementation of a Physical Design StudentCourse(studentID, courseCode) FK studentID→tblStudent Update Cascade, Delete Restrict FK courseCode→tblcourse Update Cascade, Delete Restrict Entity StudentCourse is converted to the following physical design. This entity has a Compound Key, all elements of the compound key are identified. Both attributes are foreign keys. This means that their data type and size must exactly match the data type and the field to which they will be linking to enforce the relationship between the tables. Compound keys are always indexed yes (duplicates OK) Field NameData TypeSizeFormatKey TypeIndexRequired studentIDText8Compound KeyYes(duplicates OK)Yes courseCodeText8Compound KeyYes(duplicates OK)Yes

Deanery of Business & Computer Sciences 9 SQL Create Table CREATE TABLE tblStudentCourse (studentID VARCHAR(8), courseCode VARCHAR(8), PRIMARY KEY (studentID, courseCode) ); CREATE TABLE tblStudentCourse (studentID TEXT(8), courseCode TEXT(8), PRIMARY KEY (studentID, courseCode) ); ALTERNATIVE

Deanery of Business & Computer Sciences 10 Enforcing Foreign Keys ALTER TABLE tblStudentCourse ADD CONSTRAINT courseStudentCourseFK FOREIGN KEY (courseCode) REFERENCES tblcourse (courseCode);

Deanery of Business & Computer Sciences 11 Adding data using SQL INSERT INTO targetTable (Field1, Field2, …) VALUES (Value1, Value2, …)

Deanery of Business & Computer Sciences 12 Adding data using SQL Method 1 INSERT INTO tblProduct (prodID, prodDesc, cost) VALUES (‘ssaay1’, ‘Nut’, 34.50)

Deanery of Business & Computer Sciences 13 Adding data using SQL Method 2 INSERT INTO tblProduct VALUES (‘ssaay2’, ‘screw’, 4.50);

Deanery of Business & Computer Sciences 14 INSERT INTO tblSupplier (suppName, suppAdd1, suppAdd2, suppPostCode) VALUES (‘Johnsons’, ‘34 Meols Parade’, ‘Meols’, ‘CH47 6AY’) Adding data using SQL

Deanery of Business & Computer Sciences 15 Summary Implementation of a Physical Design Use of SQL Create Table Use of SQL Alter Table to enforce foreign keys. Student individual work Rest of chapter 6

Deanery of Business & Computer Sciences 16 REMEMBER Implementation Test (3), W/B 18 th February 2008 (20%) Group Work Implementation Due 7 th March 2008