SQL Tables and Constraints Example

Slides:



Advertisements
Similar presentations
Normal forms - 1NF, 2NF and 3NF
Advertisements

Database Management System Module 3:. Complex Constraints In this we specify complex integrity constraints included in SQL. It relates to integrity constraints.
Triggers Event handlers in the DBMS. Triggers are event handlers Triggers a executed when an event happens in the DBMS Example events – INSERT, UPDATE.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
Implementing the Theory dBase Operations in MS Access.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
© 2002 by Prentice Hall 1 Database Processing with Microsoft Access David M. Kroenke Database Concepts 1e Appendix A.
1 DBS201: More on SQL Lecture 3. 2 Agenda How to use SQL to update table definitions How to update data in a table How to join tables together.
Database Design And Implementation. Done so far… Started a design of your own data model In Software Engineering, recognised the processes that occur.
Assertions and triggers1. 2 Constraints Attribute-based CHECK constraints create table … ( postcode number(4) check (postcode > 0) ); Checked at update.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Trigger used in PosgreSQL
CSIS 115 Database Design and Applications for Business
Tables & Relationships
Chapter 6: Integrity (and Security)
SQL – Part 2.
© 2016, Mike Murach & Associates, Inc.
CS 3630 Database Design and Implementation
Schema Refinement and Normal Forms
Information Systems Today: Managing in the Digital World
SQL – More Table Constraints
Foreign Keys Local and Global Constraints Triggers
CS411 Database Systems 08: Midterm Review Kazuhiro Minami 1.
Module 5: Overview of Database Design -- Normalization
Relational Database Design by Dr. S. Sridhar, Ph. D
ITEC 313 Database Programming
Relational Database Design
CS 480: Database Systems Lecture 22 March 6, 2013.
Introduction to Database Systems
Lecture 4 Database design IV Normal Forms: Summary.
Payroll Management System
Chapter 8: Relational Database Design
Database Management  .
Rules in active databases and integrity constraints
CPSC-310 Database Systems
Lecturer: Mukhtar Mohamed Ali “Hakaale”
ABC’s of Database Design
Normalization Referential Integrity
The Relational Model Relational Data Model
Schema Refinement and Normalization
Module 5: Overview of Normalization
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Teaching slides Chapter 8.
Chapter 14 Normalization – Part I Pearson Education © 2009.
PHP and MySQL.
Normalization Dale-Marie Wilson, Ph.D..
Index Use Cases.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
Retail Sales is used to illustrate a first dimensional model
Physical Design and Tuning Example
Decomposition and Higher Forms of Normalization
Unit 7 Normalization (表格正規化).
ER Modeling Case Studies
Database Design and Development
Getting to First Base: Introduction to Database Concepts
Retail Sales is used to illustrate a first dimensional model
Data Definition Language
Getting to First Base: Introduction to Database Concepts
Getting to First Base: Introduction to Database Concepts
SQL – Constraints & Triggers
Question 1: Basic Concepts (45 %)
Instructor: Samia arshad
Investigation on wins Kayla Brownfield DSCI 101 Fall 2018
Query-by-Example Transparencies
Lecture 05: SQL Wednesday, October 9, 2002.
SQL NOT NULL Constraint
Chapter 7a: Overview of Database Design -- Normalization
-Transactions in SQL -Constraints and Triggers
Database 2.
Presentation transcript:

SQL Tables and Constraints Example 1

The Database A hockey league with rinks, teams, and players: Rink (name, phone, capacity) Team (tname, city, color, wins, losses, tie, rname FK references Rink(name)) Player (id, name, num, pos, tname, tcity, FK (tname, tcity) references Team (tname, city)) All relations are in BCNF The only FDs are PKall other fields Constraint: All players with uniform number 9 must be goalies. 10

Unpreserved Dependencies Suppose the users now decide that all rinks in the same city have the same capacity: city  capacity While trying to remain calm, you realize that: This FD doesn’t exist in any single relation, so a join is required to check it each time we add or change a capacity value. The tradeoff: Expensive to check, but may not be checked often enough to justify creating a dependency-preserving decomposition.

Summary Keys can be specified: “Check” constraints very useful With the attribute, for single-field keys At end of “create table” statement (all keys) In a separate “alter table” statements (all keys) “Check” constraints very useful SQL Server: can only involve one relation SQL Standard: more general Triggers, assertions for IC (FD) enforcement SQL Server doesn’t support assertions Must be careful, in general, with triggers