Referential Integrity MySQL

Slides:



Advertisements
Similar presentations
MySQL. To start go to Login details: login: labuser password:macimd15 – There.
Advertisements

MS-Access XP Lesson 2. Input Mask Property 1.Field : Phone No Data Type : Number Input Mask : Character 0 represent a single digit and phone.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)MySQL Recap.
MySQL-Database Teppo Räisänen Oulu University of Applied Sciences School of Business and Information Management.
NMED 3850 A Advanced Online Design February 25, 2010 V. Mahadevan.
CIT 381 Data Types - data types - create table statement - constraints.
RELATIONSHIP  THE WAY TABLES ARE RELATED  A TABLE MUST PARTICIPATE IN AT LEAST ONE RELATIONSHIP  IN A BINARY RELATIONSHIP TWO ENTITIES PARTICIPATE 
SQL Keys and Constraints Justin Maksim. Key Declaration Key constraint defined within the CREATE TABLE command Key can be declared using either the PRIMARY.
Student(sid, name, addr, age, GPA) Class(dept, cnum, sec, unit, title, instructor) Enroll(sid, dept, cnum, sec) siddeptcnumsec 301CS CS AT00000.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
SQL Constraints & Triggers May 10 th, Agenda Big picture –what are constraints & triggers? –where do they appear? –why are they important? In SQL.
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
Information Systems Today (©2006 Prentice Hall) MySQL 1CS3754 Class Note #8, Is an open-source relational database management system 2.Is fast and.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
CpSc 462/662: Database Management Systems (DBMS) (TEXNH Approach) Constraints, Triggers and Index James Wang.
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.
Dec 8, 2003Murali Mani Constraints B term 2004: lecture 15.
Introduction to Database System Adisak Intana Lecturer Chapter 7 : Data Integrity.
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
CREATE TABLE ARTIST ( ArtistID int NOT NULL IDENTITY (1,1), Namechar(25) NOT NULL, TEXT ERROR Nationality char (30) NULL, Birthdate numeric (4,0) NULL,
SQL constrains and keys. SORTED RESULTS Sort the results by a specified criterion SELECT columns FROM tables WHERE predicates ORDER BY column ASC/DESC;
Working with MySQL A290/A590, Fall /07/2014.
Dorm Name PK Occupancy Dorm Name PK Occupancy HighResDorm StartDate HighResDorm StartDate LowResDorm StartDate WaterSensorID WaterOnLineDate ElecSensorID.
Databases Introduction - concepts. Concepts of Relational Databases.
IS232 Lab 9. CREATE USER Purpose: Use the CREATE USER statement to create and configure a database user, which is an account through which you can log.
Getting started with Accurately Storing Data
Tables & Relationships
CS320 Web and Internet Programming SQL and MySQL
MySQL-Database Jouni Juntunen Oulu University of Applied Sciences
Introduction to PHP and MySQL – Creating Database-Driven Websites
Database Keys and Constraints
CS311 Database Management system
BookStore App as a console app
Relation (Table) Row/Tuple/Record Column/Attribute/Field name birth
MySQL Explain examples
SQL: Constraints and Triggers
Referential Integrity
Relation (Table) Row/Tuple/Record Column/Attribute/Field name birth
Lecturer: Mukhtar Mohamed Ali “Hakaale”
لغة قواعد البيانات STRUCTURED QUERY LANGUAGE SQL))
PHPMyAdmin.
For student, require values for name and address.
HSCI 709 MySQL Lecture 13.
Referential Integrity
אבטחת נתונים בסביבת SQL Data Security
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
SQL Code for Byrnetube video
CS122 Using Relational Databases and SQL
CS122 Using Relational Databases and SQL
Rob Gleasure robgleasure.com
CS 142 Lecture Notes: Relational Databases
CS3220 Web and Internet Programming SQL and MySQL
CS1222 Using Relational Databases and SQL
Data Definition Language
Data Definition Language
Chapter 4 Introduction to MySQL.
CS122 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
CS122 Using Relational Databases and SQL
CS3220 Web and Internet Programming SQL and MySQL
Instructor: Samia arshad
Relational Data Model - 2
CS122 Using Relational Databases and SQL
ETL Processing Mechanics of ETL.
CS122 Using Relational Databases and SQL
SQLDeveloper Data Modeler - Logical Model
កម្មវិធីបង្រៀន SQL Programming ជាភាសាខ្មែរ Online SQL Training Course
SQL NOT NULL Constraint
SQL AUTO INCREMENT Field
Presentation transcript:

Referential Integrity MySQL CREATE TABLE exmp1( id INT NOT NULL, val TEXT, UNIQUE (id) ) TYPE=InnoDB; CREATE TABLE exmp2( id INT, blah TEXT, INDEX(id), CONSTRAINT id_fkey FOREIGN KEY (id) REFERENCES exmp1(id) ON UPDATE CASCADE ) TYPE=InnoDB;

Examples:Zoo animals CREATE TABLE species (id TINYINT NOT NULL AUTO_INCREMENT, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) TYPE=INNODB; INSERT INTO species VALUES (1, 'orangutan'), (2, 'elephant'), (3, 'hippopotamus'), (4, 'yak'); CREATE TABLE zoo (id INT(4) NOT NULL, name VARCHAR(50) NOT NULL, FK_species TINYINT(4) NOT NULL, INDEX (FK_species), constraint FOREIGN KEY (FK_species) REFERENCES species (id) on update cascade, PRIMARY KEY(id)) TYPE=INNODB; INSERT INTO zoo VALUES (1, 'Harry', 5); //error:violate R.I. INSERT INTO zoo VALUES (1, 'Harry', 2);//OK Update species set id=5 where name=‘elephant’;//change zoo too