Chapter 1 SQL and Data

Similar documents
Solved MCQ on fundamental of DBMS. Set-1

Database Management System 9

Review -Chapter 4. Review -Chapter 5

SQL language. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

Course Outline Faculty of Computing and Information Technology

Techno India Batanagar Computer Science and Engineering. Model Questions. Subject Name: Database Management System Subject Code: CS 601

Basant Group of Institution

Mahathma Gandhi University

normalization are being violated o Apply the rule of Third Normal Form to resolve a violation in the model

Sample Question Paper

Review for Exam 1 CS474 (Norton)

Using SQL with SQL Developer 18.1 Part II

Deccansoft softwareservices-microsoft Silver Learing Partner. SQL Server Syllabus

Relation Databases. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region. Based on CBSE Curriculum Class -11. Neha Tyagi, PGT CS II Shift Jaipur

Assignment Session : July-March

Data about data is database Select correct option: True False Partially True None of the Above

Oracle Database 10g: Introduction to SQL

Data Modelling and Databases. Exercise Session 7: Integrity Constraints

II B.Sc(IT) [ BATCH] IV SEMESTER CORE: RELATIONAL DATABASE MANAGEMENT SYSTEM - 412A Multiple Choice Questions.

Mastering Transact-SQL An Overview of SQL Server 2000 p. 3 SQL Server's Networked Architecture p. 4 SQL Server's Basic Components p.

Using SQL with SQL Developer Part II

8) A top-to-bottom relationship among the items in a database is established by a

Concepts of Database Management Seventh Edition. Chapter 4 The Relational Model 3: Advanced Topics


The Relational Model. Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC)

SQL Interview Questions

Relational Database Components

Fundamentals, Design, and Implementation, 9/e Copyright 2004 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M.

DATABASES SQL INFOTEK SOLUTIONS TEAM

Entity Attribute STUDENT TABLE tuples single domain

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1

Lab # 2. Data Definition Language (DDL) Eng. Alaa O Shama

Creating databases using SQL Server Management Studio Express

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1

Business Analytics. SQL PL SQL [Oracle 10 g] P r i n c e S e t h i w w w. x l m a c r o. w e b s. c o m

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210

In This Lecture. SQL Data Definition SQL SQL. Non-Procedural Programming. Notes. Database Systems Lecture 5 Natasha Alechina

Top 88 Question Asked in Part I of MIS 150 EXAM #1 (Chapter 1-4, Appendix C) Exams questions gathered from old tests dating back to Fall 2000

Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata

Indexes (continued) Customer table with record numbers. Source: Concepts of Database Management

Index *EXTIND option, ADDPFTRG command. See CL command Alias CREATE ALIAS for, 62, 64 for a column, 22, for a table, 15-17, 62, 66-67,

Oracle User Administration

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

EDUVITZ TECHNOLOGIES

The Structured Query Language Get Started

Today Learning outcomes LO2

Data analysis and design Unit number: 23 Level: 5 Credit value: 15 Guided learning hours: 60 Unit reference number: H/601/1991.

The Relational Model

Using SQL with SQL Developer 18.2

The Relational Model Constraints and SQL DDL

Oracle. SQL(Structured Query Language) Introduction of DBMS. Build In Function. Introduction of RDBMS. Grouping the Result of a Query

Objectives of logical design... Transforming the ERD diagram into relations. Relational database components. Mapping a composite attribute

Index. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer,

5. Single-row function

Lab # 4. Data Definition Language (DDL)

Chapter # 7 Introduction to Structured Query Language (SQL) Part I

Oracle Database 11g: SQL and PL/SQL Fundamentals

Introduction to Computer Science and Business

SQL: Data De ni on. B0B36DBS, BD6B36DBS: Database Systems. h p:// Lecture 3

Database Systems Overview. Truong Tuan Anh CSE-HCMUT

1D D0-541 CIW v5 Database Design Specialist Version 1.7

MySQL Introduction. By Prof. B.A.Khivsara

Overview. Data Integrity. Three basic types of data integrity. Integrity implementation and enforcement. Database constraints Transaction Trigger

Data, Databases, and DBMSs

Microsoft Office Access 2007: Intermediate Course 01 Relational Databases

! Define terms. ! Interpret history and role of SQL. ! Write single table queries using SQL. ! Establish referential integrity using SQL

ORACLE DATABASE 12C INTRODUCTION

AO3 - Version: 2. Oracle Database 11g SQL

Chapter 4: SQL Basics

Vendor: CIW. Exam Code: 1D Exam Name: CIW v5 Database Design Specialist. Version: Demo

(ADVANCED) DATABASE SYSTEMS (DATABASE MANAGEMENTS) PROF. DR. HASAN HÜSEYİN BALIK (6 TH WEEK)

M.C.A. (CBCS) Sem.-III Examination November-2013 CCA-3004 : Database Concepts and Tools. Faculty Code: 003 Subject Code:

COMP 3400 Mainframe Administration 1

JSPM s Bhivarabai Sawant Institute of Technology & Research, Wagholi, Pune Department of Information Technology

3ISY402 DATABASE SYSTEMS

Oracle Create Table Foreign Key On Delete No


Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Structured Query Language (SQL): A Primer on Data Definition Language (DDL)

Oracle Syllabus Course code-r10605 SQL

Oracle SQL & PL SQL Course

Table of Contents. PDF created with FinePrint pdffactory Pro trial version

THE RELATIONAL DATABASE MODEL

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

1 Prepared By Heena Patel (Asst. Prof)

A Unit of SequelGate Innovative Technologies Pvt. Ltd. All Training Sessions are Completely Practical & Real-time

Example 1 - Create Horizontal View. Example 2 - Create Vertical View. Views. Views

MySQL Database Administrator Training NIIT, Gurgaon India 31 August-10 September 2015

Lecture7: SQL Overview, Oracle Data Type, DDL and Constraints Part #2

1D0-541_formatted. Number: Passing Score: 800 Time Limit: 120 min File Version: 1.

Relational Database Systems Part 01. Karine Reis Ferreira

Full file at

COSC344 Database Theory and Applications. Lecture 5 SQL - Data Definition Language. COSC344 Lecture 5 1

Exam code: Exam name: Database Fundamentals. Version 16.0

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

Lecture 08. Spring 2018 Borough of Manhattan Community College

CGS 3066: Spring 2017 SQL Reference

The Relational Model. Roadmap. Relational Database: Definitions. Why Study the Relational Model? Relational database: a set of relations

The Relational Model. Outline. Why Study the Relational Model? Faloutsos SCS object-relational model

Transcription:

Chapter 1 SQL and Data What is SQL? Structured Query Language An industry-standard language used to access & manipulate data stored in a relational database E. F. Codd, 1970 s IBM 2 What is Oracle? A relational database management system (DBMS) software that allows the creation, retrieval, and manipulation of data We will retrieve data to answer questions add records delete records change field values so they re up-to-date create new tables define relationships between tables define constraints to ensure data integrity create views, sequences, indexes control user access to database objects 3 1

Overview of SQL Language Commands Data Manipulation Language (DML) (Chapters 2-11) commands to retrieve or modify the contents of a table SELECT, INSERT, UPDATE, DELETE Data Definition Language (DDL) (Chapters 12, 13) commands to create or modify database objects tables, views, sequences, indexes, stored procedures CREATE, ALTER, DROP Data Control Language (DCL) (Chapter 15) commands to control user privileges (access to database objects) GRANT, REVOKE 4 Primary and Foreign Keys How do we connect (join) related data that has been stored in separate tables? Primary Key 3 properties of how indicated on schema diagram? Foreign key how indicated on schema diagram? 5 Additional Primary Key Topics Candidate key Composite (concatenated) primary key Natural primary key Synthetic primary key 6 2

Columns and Datatypes When a table is created, each column is declared to contain data of a particular type Example datatypes: varchar2(10) char(10) number(6,2) date Domain the set of permissible values from which a column draws its actual values 7 Schema A collection of objects owned by a database user and having the same name as the user egs: tables, views, indexes, sequences, synonyms, stored procedures, functions, triggers, packages Schema Diagram a pictorial representation of a database s tables and its inter-table relationships Student Schema (Appendix D) Issue25 Schema 8 Data Redundancy What is it? Three main problems it causes: Issue25 handout 9 3

One-to-Many Relationships (1:M) The most common type of inter-table relationship Each row in Table A can have many (zero or more) matching rows in Table B but each row in Table B has only one matching row in Table A. each ZipCode can have many Students but each Student has only one ZipCode each Course can be associated with many Sections but each Section covers only one Course include the primary key of the one table as a foreign key in the many table How depicted in a schema diagram? join line: crows feet and single line 10 Many:Many Relationships (M:M) Each row in Table A can have many matching rows in Table B & each row in Table B can have many matching rows in Table A. each Pitcher can pitch in many Games and each Game can use many Pitchers each Author can write many Books and each Book can be written by many Authors Figure 1.16, pg 18 create a third table (intersection table, junction table) and include each table s primary key as foreign keys doing so breaks the Many:Many relationship into two separate 1:Many relationships How depicted in a schema diagram? 11 junction table and 2 join lines One-to-One Relationships (1:1) Each row in one table has at most one matching row in the other table Two tables whose primary keys are the same and also serve as foreign keys to the other table Columns in one table are additional attributes for the other table Figure 1.14, pg 17 Commonly used to avoid nulls control field access 12 4

Join Lines Each join line runs between two tables and can be read in two directions Cardinality indicates whether a table can have 0, 1, or Many matching rows in the related table single line or crow s feet Optional/Mandatory Relationships circle indicates optional relationship vertical bar indicates mandatory relationship Figure 1.17, pg 19 each PUBLISHER may publish 0, 1, or many BOOKs there can be publishers with no matching books each BOOK must be published by 1 PUBLISHER each book s PUBLISHER_ID must have a value (NOT NULL) 13 Database Development Requirements Analysis identify user needs, data elements Conceptual Data Model group attributes (data elements) into entities; unique identifiers Logical Data Model normalization process; ERD; primary & foreign keys identified general data type for each attribute M:M relationships resolved Physical Data Model is platform specific column names, datatypes, relationships, schema diagram use SQL statements to create the tables and other objects 14 Referential Integrity Each foreign key value must match a primary key value in the related table if a row in one table references a row in another, the referenced row must exist Rules to ensure that data stored in related tables stays in synch with each other prevents orphan records in a related table How can we prevent null foreign keys? 15 5

Referential Integrity When INSERT a new record to a child table and specify a value for a foreign key field, a matching record must already exist in the primary table e.g.: when add a new Article, the WriterID you enter must match an existing WriterID in the Writer table Can t UPDATE an existing record s primary key value in the primary table when there are matching records the child table e.g.: change a Writer s WriterID Can t DELETE an existing record from a primary table when matching records exist in a child table (unless cascade the delete) e.g.: delete a Writer 16 Recursive Relationship A.k.a. Self-Referencing relationship A table containing a foreign key that relates to its own primary key How depicted in a schema diagram? Which table has a recursive relationship in the Student schema? Issue25 schema? 17 6