1 Lecture 1 Introduction Based on

Slides:



Advertisements
Similar presentations
1 More SQL Database Modification Defining a Database Schema Views.
Advertisements

Tallahassee, Florida, 2014 COP4710 Database Systems Relational Model Fall 2014.
Chapter 7 Notes on Foreign Keys Local and Global Constraints Triggers.
1 More SQL Database Modification Defining a Database Schema Views Source: slides by Jeffrey Ullman.
Constraints and Triggers Foreign Keys Local and Global Constraints Triggers.
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)
1 CS145 Introduction About CS145 Relational Model, Schemas, SQL Semistructured Model, XML.
1 Constraints Foreign Keys Local and Global Constraints Triggers.
Winter 2002Arthur Keller – CS 1809–1 Schedule Today: Jan. 31 (TH) u Constraints. u Read Sections , Project Part 3 due. Feb. 5 (T) u Triggers,
1 Constraints Foreign Keys Local and Global Constraints Triggers.
CPSC-608 Database Systems Fall 2011 Instructor: Jianer Chen Office: HRBB 315C Phone: Notes #4.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
Fall 2001Arthur Keller – CS 1809–1 Schedule Today Oct. 23 (T) Constraints. u Read Sections Assignment 4 due. Project Part 3 due Oct. 24 (W). Oct.
CPSC-608 Database Systems Fall 2008 Instructor: Jianer Chen Office: HRBB 309B Phone: Notes #3.
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.
DB Modifications Modification = insert + delete + update. Insertion of a Tuple INSERT INTO relation VALUES (list of values). Inserts the tuple = list of.
Database Systems Chapter 1 The Worlds of Database Systems.
Database Lecture # 1 By Ubaid Ullah.
Module Title? DBMS Introduction to Database Management System.
1 CS351 Introduction to Database systems
SCUHolliday - coen 1789–1 Schedule Today: u Constraints, assertions, triggers u Read Sections , 7.4. Next u Triggers, PL/SQL, embedded SQL, JDBC.
Database Technical Session By: Prof. Adarsh Patel.
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 CE223 Database Systems Introduction DBMS Overview, Relational Model, Schemas, SQL Semistructured Model, XML.
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.
Winter 2006Keller, Ullman, Cushing9–1 Constraints Commercial relational systems allow much more “fine-tuning” of constraints than do the modeling languages.
CS411 Database Systems Kazuhiro Minami 06: SQL. Constraints & Triggers Foreign Keys Local and Global Constraints Triggers.
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.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
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.
Advanced Database CS-426 Week 1 - Introduction. Database Management System DBMS contains information about a particular enterprise Collection of interrelated.
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.
1 More SQL uDatabase Modification uDefining a Database Schema uViews.
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.
Himanshu GuptaCSE 532-SQL-1 SQL. Himanshu GuptaCSE 532-SQL-2 Why SQL? SQL is a very-high-level language, in which the programmer is able to avoid specifying.
Databases : SQL-Schema Definition and View 2007, Fall Pusan National University Ki-Joune Li These slides are made from the materials that Prof. Jeffrey.
1 Constraints, Views, Indexes Foreign Keys Constraints Triggers Virtual and Materialized Views Speeding Accesses to Data.
SCUHolliday - coen 1789–1 Schedule Today: u Constraints, assertions, triggers u Read Sections , 7.4. Next u Embedded SQL, JDBC. u Read Sections.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
1 Introduction to Database Systems, CS420 SQL Constraints.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
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 Design of databases. E/R model (entity-relationship model) Relational model (tables) UML (unified modeling language) Database programming. SQL, Relational.
Fundamental of Database Systems
CPSC-310 Database Systems
Relational Data Model Lu Chaojun, SJTU.
CPSC-310 Database Systems
Introduction to Database Systems, CS420
Introduction to Database Systems, CS420
Database Design and Programming
CPSC-608 Database Systems
CS 440 Database Management Systems
Database Models Relational Model
CPSC-310 Database Systems
CMSC-461 Database Management Systems
CPSC-608 Database Systems
CPSC-608 Database Systems
CMSC-461 Database Management Systems
CE223 Database Systems Introduction
Instructor: Zhe He Department of Computer Science
Presentation transcript:

1 Lecture 1 Introduction Based on CS4416 Database Systems CS5122 Development of IS 2

2 What is a Database? uCollection of information: wExists over a long period of time wStored on secondary storage in a structured way. wManaged by a computer program called Database Management System (DBMS) uPopular DBMSs: Oracle, IBM DB2, Microsoft SQL Server, Teradata, Sybase IQ, Microsoft Access, MySQL, PostgreSQL, SQLite, db4o

3 What is a Database? (contd.) DBMS DATA User (person/application)

4 What is a Database? (contd.) uDBMS is expected to: wAllow users to create new databases and specify their schemas, using a data-definition language (DDL). Schema – logical structure of the data wGive users the ability to query and modify the data using a data- manipulation/query language (DML). The most commonly used query language is SQL. wSupport the storage of very large amounts of data over a long period of time, allowing efficient access to the data for queries and database modifications. wEnable durability, the recovery of database in the face of failures, errors of many kinds, or intentional misuse. wControl access to data from many users at once without allowing unexpected interactions among the users – isolation without actions on the data to be performed partially but not completely - atomicity

5 What is a Database? (contd.) DBMS DATA User or application Database administrator queries, updates (DML) schema-altering commands (DDL)

6 DBMS Evolution uFile Systems uFirst important applications of DBMS’s: wBanking systems wAirline reservation systems wCorporate record keeping Employment and tax records Inventories Sales records, etc. uEarly DBMS’s required the programmer to visualize data as it is stored: wHierarchical data model wNetwork data model

7 DBMS Evolution (contd.) uRelational database systems wTed Codd, 1970: Database systems should present the user with a view of data organised as tables called relations wQueries could be expressed in a very high-level language wNorm by 1990 uSome of the largest databases are organised differently from those using the relational methodology. uObject (Object-oriented) database systems.

8 Interesting Stuff About Databases uIt used to be about boring stuff: employee records, bank records, etc. uToday, the field covers all the largest sources of data, with many new ideas. wWeb search. wData mining. wScientific and medical databases. wIntegrating information.

9 Module Outline uRelational Database Modelling wThe Relational Data Model wDesign Theory of Relational Databases uRelational Database Programming wSQL: The Database Language wConstraints and Triggers wViews and Indexes wSQL in Server Environment The SQL/Host Language Interface Stored Procedures JDBC, PHP & MySQL, Android & SQLite uLabs: Oracle, MySQL

10 Data Models

11 What is a Data Model? Notation for describing data or information: wStructure of the data. conceptual data model wOperations on data. Queries, modifications wConstraints.

12 What is a Database? (contd.) DBMS DATA User or application Database administrator queries, updates (DML) schema-altering commands (DDL) Conceptual Data Model Physical Data Model

13 Important Data Models uRelational model – including object- relational extensions uSemistructured-data model, including XML and related standards.

14 Relational Data Model

15 A Relation is a Table name manf WinterbrewPete’s Bud LiteAnheuser-Busch Beers Attributes (column headers) Tuples (rows) Relation name

16 Schemas uRelation schema = relation name and attribute list. wOptionally: types of attributes. wExample: Beers(name, manf) or Beers(name: string, manf: string) uDatabase = collection of relations. uDatabase schema = set of all relation schemas in the database.

17 Why Relations? uVery simple model. uOften matches how we think about data. uAbstract model that underlies SQL, the most important database language today.

18 Do You Know SQL? uExplain the difference between: SELECT b FROM R WHERE a =10; and SELECT b FROM R; ab R

19 And How About These? SELECT a FROM R, S WHERE R.b = S.b; SELECT a FROM R WHERE b IN (SELECT b FROM S); ab R cb S

20 Our Running Example Beers(name, manf) Bars(name, addr, license) Drinkers(name, addr, phone) Likes(drinker, beer) Sells(bar, beer, price) Frequents(drinker, bar) uUnderline = key (tuples cannot have the same value in all key attributes). wExcellent example of a constraint.

21 Database Schemas in SQL uSQL is primarily a query language, for getting information from a database. uBut SQL also includes a data-definition component for describing database schemas.

22 Creating (Declaring) a Relation uSimplest form is: CREATE TABLE ( ); uTo delete a relation: DROP TABLE ;

23 Elements of Table Declarations uMost basic element: an attribute and its type. uThe most common types are: wINT or INTEGER (synonyms). wREAL or FLOAT (synonyms). wCHAR(n ) = fixed-length string of n characters. wVARCHAR(n ) = variable-length string of up to n characters.

24 Example: Create Table CREATE TABLE Sells ( barCHAR(20), beerVARCHAR(20), priceREAL );

25 SQL Values uIntegers and reals are represented as you would expect. uStrings are too, except they require single quotes.  Two single quotes = real quote, e.g., ’Joe’’s Bar’. uAny value can be NULL.

26 Dates and Times uDATE and TIME are types in SQL. uThe form of a date value is: DATE ’yyyy-mm-dd’  Example: DATE ’ ’ for Sept. 30, 2007.

27 Times as Values uThe 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.

28 Declaring Keys uAn attribute or list of attributes may be declared PRIMARY KEY or UNIQUE. uEither says that no two tuples of the relation may agree in all the attribute(s) on the list. uThere are a few distinctions to be mentioned later.

29 Declaring Single-Attribute Keys uPlace PRIMARY KEY or UNIQUE after the type in the declaration of the attribute. uExample: CREATE TABLE Beers ( nameCHAR(20) UNIQUE, manfCHAR(20) );

30 Declaring Multiattribute Keys uA key declaration can also be another element in the list of elements of a CREATE TABLE statement. uThis form is essential if the key consists of more than one attribute. wMay be used even for one-attribute keys.

31 Example: Multiattribute Key uThe bar and beer together are the key for Sells: CREATE TABLE Sells ( barCHAR(20), beerVARCHAR(20), priceREAL, PRIMARY KEY (bar, beer) );

32 PRIMARY KEY vs. UNIQUE 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.