1. 2 Design of databases. E/R model (entity-relationship model) Relational model (tables) UML (unified modeling language) Database programming. SQL, Relational.

Slides:



Advertisements
Similar presentations
Tallahassee, Florida, 2014 COP4710 Database Systems Relational Model Fall 2014.
Advertisements

1 More SQL Database Modification Defining a Database Schema Views Source: slides by Jeffrey Ullman.
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.
1 More SQL Defining a Database Schema Views. 2 Defining a Database Schema uA database schema comprises declarations for the relations (“tables”) of the.
Winter 2002Arthur Keller – CS 1808–1 Schedule Today: Jan. 29 (T) u Modifications, Schemas, Views. u Read Sections Assignment 3 due. Jan. 31 (TH)
Winter 2002Judy Cushing8–1 Schedule Jan. 30 (Wed) u Modifications, Schemas, Views. Read Sections This Week (Feb 4ff) u Constraints Read Sections.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
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.
CPSC-608 Database Systems Fall 2008 Instructor: Jianer Chen Office: HRBB 309B Phone: Notes #3.
Chapter 12 Representing Data Elements By Yue Lu CS257 Spring 2008 Instructor: Dr.Lin.
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.
CPSC-608 Database Systems Fall 2011 Instructor: Jianer Chen Office: HRBB 315C Phone: Notes #2.
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.
CSCI 6962: Server-side Design and Programming
1 CS351 Introduction to Database systems
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.
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.
1 CE223 Database Systems Introduction DBMS Overview, Relational Model, Schemas, SQL Semistructured Model, XML.
1 Lecture 1 Introduction Based on
Constraints on Relations Foreign Keys Local and Global Constraints Triggers Following lecture slides are modified from Jeff Ullman’s slides
Databases 1 Fourth lecture. Rest of SQL Defining a Database Schema Views Foreign Keys Local and Global Constraints Triggers 2.
Module 5 Planning for SQL Server® 2008 R2 Indexing.
1 CS1368 Introduction* Relational Model, Schemas, SQL Semistructured Model, XML * The slides in this lecture are adapted from slides used in Standford's.
RELATIONAL DATA MODEL 1. 2 What is a Data Model? 1.Mathematical representation of data. wExamples: relational model = tables; semistructured model = trees/graphs.
Concepts of Database Management Seventh Edition
1 Introduction Relational Model, Schemas, SQL Semistructured Model, XML The slides were made by Jeffrey D. Ullman for the Introduction to Databases course.
SCUHolliday - coen 1788–1 Schedule Today u Modifications, Schemas, Views. u Read Sections (except and 6.6.6) Next u Constraints. u Read.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Jeff Ullman: Introduction to XML 1 XML Semistructured Data Extensible Markup Language Document Type Definitions.
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.
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.
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.
Introduction to SQL Introduction Select-From-Where Statements Queries over Several Relations Subqueries.
Databases : SQL-Schema Definition and View 2007, Fall Pusan National University Ki-Joune Li These slides are made from the materials that Prof. Jeffrey.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Database Design and Programming Jan Baumbach Adopted from previous slides of Peter Schneider-Kamp.
1. 2 Standards group: ODMG = Object Data Management Group. ODL = Object Description Language, like CREATE TABLE part of SQL. OQL = Object Query Language,
CPSC 603 Database Systems Lecturer: Laurie Webster II, Ph.D., P.E.
CMPT 354 Database Systems I
CPSC-310 Database Systems
Database Design and Programming
Relational Data Model Lu Chaojun, SJTU.
COP4710 Database Systems Relational Model.
Introduction to Database Systems, CS420
Introduction to Database Systems, CS420
Database Design and Programming
CPSC-310 Database Systems
CPSC-608 Database Systems
Database Construction and Usage
CPSC-608 Database Systems
Database Models Relational Model
ORACLE SQL Developer & SQLPLUS Statements
CPSC-310 Database Systems
Instructor: Mohamed Eltabakh
SQL OVERVIEW DEFINING A SCHEMA
Defining a Database Schema
SQL-1 Week 8-9.
Session - 6 Sequence - 1 SQL: The Structured Query Language:
CPSC-608 Database Systems
CPSC-608 Database Systems
Session - 6 Sequence - 1 SQL: The Structured Query Language:
CPSC-608 Database Systems
CMSC-461 Database Management Systems
CE223 Database Systems Introduction
Instructor: Zhe He Department of Computer Science
Presentation transcript:

1

2 Design of databases. E/R model (entity-relationship model) Relational model (tables) UML (unified modeling language) Database programming. SQL, Relational algebra Interface from Java and.NET framework Data security.

3 Database Systems: The Complete Book, 2/E ISBN-13: NOTE: THE BOOK IS A MUST Some handouts given by the instructor Power point presentations (not sure!)

4 Test1: 15% Midterm: 20% Final: 35% Project: 20%. Any project supported by a database is acceptable. Individual Assignments: 10%. Exercises from the book in addition to some challenging ones. Individual – No late policy

5 SOE rules and regulation Important dates Absences and late policy usage SP courses policy Labs Office hours

6 Do not come to lectures Do not do assignments or start late Do not ask questions in class Do not come to see me during office hours Cheating is also an option

7 In the LAB we will use: Microsoft SQL server 2008 Oracle database 11g Visual studio Java JDK 6 Each of you should duplicate this environment on his home computer. It is needed for assignments and practices. An 8GB flash memory is required to exchange data

8 name mark CorollaToyota CR-VHonda Cars Attributes (column headers) Tuples (rows) Relation name

9 Relation schema = relation name and attribute list. Optionally: types of attributes. Example: Cars(name, mark) or Cars(name: string, mark: string) Database = collection of relations. Database schema = set of all relation schemas in the database.

10 Very simple model. Often matches how we think about data. Abstract model that underlies SQL, the most important database language today.

11 Underline indicates key attributes. Cars(name, mark) Garage( name, addr, license) Customers(name, addr, phone) Drives(customer, car) Serves (garage, car, service, price) Frequents( customer, garage)

12 SQL is primarily a query language, for getting information from a database. But SQL also includes a data-definition component for describing database schemas.

13 Simplest form is: CREATE TABLE ( ); To delete a relation: DROP TABLE ;

14 Most basic element: an attribute and its type. The most common types are: INT or INTEGER (synonyms). REAL or FLOAT (synonyms). CHAR(n ) = fixed-length string of n characters. VARCHAR(n ) = variable-length string of up to n characters.

15 CREATE TABLE Serves ( garageCHAR(20), carVARCHAR(20), serviceVARCHAR(20), priceREAL );

16 Integers and reals are represented as you would expect. Strings are too, except they require single quotes. Two single quotes = real quote, e.g., ’Tools’’ garage’. Any value can be NULL.

17 DATE and TIME are types in SQL. The form of a date value is: DATE ’yyyy-mm-dd’ Example: DATE ’ ’ for Sept. 30, 2007.

18 The form of a time value is: TIME ’hh:mm:ss’ with an optional decimal point and fractions of a second following. Example: TIME ’15:30:02.5’ = two and a half seconds after 3:30PM.

19 An attribute or list of attributes may be declared PRIMARY KEY or UNIQUE. Either says that no two tuples of the relation may agree in all the attribute(s) on the list. There are a few distinctions to be mentioned later.

20 Place PRIMARY KEY or UNIQUE after the type in the declaration of the attribute. Example: CREATE TABLE Cars ( nameCHAR(20) UNIQUE, markCHAR(20) );

21 A key declaration can also be another element in the list of elements of a CREATE TABLE statement. This form is essential if the key consists of more than one attribute. May be used even for one-attribute keys

22 The garage, car and service together are the key for Serves: CREATE TABLE Serves( garageCHAR(20), carVARCHAR(20), serviceVARCHAR(20), priceREAL, PRIMARY KEY (garage,car,service) );

23 1.There can be only one PRIMARY KEY for a relation, but several UNIQUE attributes. 2.No attribute of a PRIMARY KEY can ever be NULL in any tuple. But attributes declared UNIQUE may have NULL’s, and there may be several tuples with NULL.

24 Another data model, based on trees. Motivation: flexible representation of data. Motivation: sharing of documents among systems and databases.

25 Nodes = objects. Labels on arcs (like attribute names). Atomic values at leaf nodes (nodes with no arcs out). Flexibility: no restriction on: Labels out of a node. Number of successors with a given label.

26 Tiida A.B. Gold1995 Bchamoun Tools Tiida car garage mark servedAt name addr prize yearaward root The garage object for Tools’ garage The car object for Tiida Notice a new kind of data.

27 From the start menu, select SQL Server Management Studio In the connect to server window select Connect You are now connected to the SQL server.

28 From the main menu, select New Query You are now ready to create your first database Write the following query create database [CarService] GO Now click on Execute to run the query

29 In the object explorer window, expand the databases Notice the creation of your database Expand the CarService database

30 We need now to create the following tables: Cars(name(20), mark(20)) Garage( name(20), addr(40), license(10)) Customers(name(40), addr(40), phone(9)) Drives(customer(40), car(10)) Serves (garage(20), car(20), service(10), price()) Frequents( customer(40), garage(20)) Underlined attributes are primary keys

31 Let’s start with the Cars table Cars(name(20), mark(20)) use [CarService] create table Cars ( name CHAR(20), mark CHAR(20), primary key (name) ); Similarly create the other tables Garage( name(20), addr(40), license(10)) Customers(name(40), addr(40), phone(9)) Drives(customer(40), car(10)) Serves (garage(20), car(20), service(10), price()) Frequents( customer(40), garage(20))