QUIZ 1 REVIEW SESSION DATABASE MANAGEMENT SYSTEMS

Similar documents
Functional Dependencies CS 1270

DATABASE MANAGEMENT SYSTEMS

COMP7640 Assignment 2

Relational Model, Relational Algebra, and SQL

2.2.2.Relational Database concept

Database Management Systems Paper Solution

Chapter 2: Intro to Relational Model

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

CMSC 461 Final Exam Study Guide

Informationslogistik Unit 5: Data Integrity & Functional Dependency

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

Database Design Principles

WHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints

University of Massachusetts Amherst Department of Computer Science Prof. Yanlei Diao

This lecture. Databases -Normalization I. Repeating Data. Redundancy. This lecture introduces normal forms, decomposition and normalization.

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

Databases -Normalization I. (GF Royle, N Spadaccini ) Databases - Normalization I 1 / 24

CS/B.Tech/CSE/New/SEM-6/CS-601/2013 DATABASE MANAGEMENENT SYSTEM. Time Allotted : 3 Hours Full Marks : 70

Chapter 2: Intro to Relational Model

CMP-3440 Database Systems

CS 377 Database Systems

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

Chapter 8: Relational Database Design

Relational Model and Relational Algebra A Short Review Class Notes - CS582-01

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization

UNIT 3 DATABASE DESIGN

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select,

RELATIONAL DATA MODEL: Relational Algebra

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 10-2

Example Examination. Allocated Time: 100 minutes Maximum Points: 250

CSCI 127 Introduction to Database Systems

Unit- III (Functional dependencies and Normalization, Relational Data Model and Relational Algebra)

Typical relationship between entities is ((a,b),(c,d) ) is best represented by one table RS (a,b,c,d)

Chapter 10. Normalization. Chapter Outline. Chapter Outline(contd.)

Relational Database Design (II)

Fundamentals of Database Systems

Unit 3 : Relational Database Design

RELATIONAL DATA MODEL

Mahathma Gandhi University

UNIT- II (Relational Data Model & Introduction to SQL)

Chapter 10. Chapter Outline. Chapter Outline. Functional Dependencies and Normalization for Relational Databases

MIDTERM EXAMINATION Spring 2010 CS403- Database Management Systems (Session - 4) Ref No: Time: 60 min Marks: 38

CS 461: Database Systems. Final Review. Julia Stoyanovich


Relational Database: The Relational Data Model; Operations on Database Relations

Babu Banarasi Das National Institute of Technology and Management

Operations of Relational Algebra

PES Institute of Technology Bangalore South Campus (1 K.M before Electronic City,Bangalore ) Department of MCA. Solution Set - Test-II

Normalization. Murali Mani. What and Why Normalization? To remove potential redundancy in design

Mapping ER Diagrams to. Relations (Cont d) Mapping ER Diagrams to. Exercise. Relations. Mapping ER Diagrams to Relations (Cont d) Exercise

Schema Refinement and Normal Forms

Relational Algebra. Procedural language Six basic operators

Chapter 6 The Relational Algebra and Calculus

Basant Group of Institution

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

Final Review. Zaki Malik November 20, 2008

Informationslogistik Unit 4: The Relational Algebra

Chapter 8: The Relational Algebra and The Relational Calculus

CS403- Database Management Systems Solved MCQS From Midterm Papers. CS403- Database Management Systems MIDTERM EXAMINATION - Spring 2010

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

Relational Algebra. Relational Algebra. 7/4/2017 Md. Golam Moazzam, Dept. of CSE, JU

Relational Model: History

NJIT Department of Computer Science PhD Qualifying Exam on CS 631: DATA MANAGEMENT SYSTEMS DESIGN. Summer 2012

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization

Informal Design Guidelines for Relational Databases

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

Database Management System 15

Draw A Relational Schema And Diagram The Functional Dependencies In The Relation >>>CLICK HERE<<<

FINAL EXAM REVIEW. CS121: Introduction to Relational Database Systems Fall 2018 Lecture 27

Chapter 14. Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies

The Entity Relationship Model

D.K.M COLLEGE FOR WOMEN(AUTONOMOUS),VELLORE DATABASE MANAGEMENT SYSTEM QUESTION BANK

Week. Lecture Topic day (including assignment/test) 1 st 1 st Introduction to Module 1 st. Practical

Conceptual (high-level, semantic)/ Physical (low-level, internal)/ Implementation (representational)

CS34800 Information Systems. The Relational Model Prof. Walid Aref 29 August, 2016

Functional Dependencies & Normalization for Relational DBs. Truong Tuan Anh CSE-HCMUT

CS2300: File Structures and Introduction to Database Systems

ADVANCED DATABASES ; Spring 2015 Prof. Sang-goo Lee (11:00pm: Mon & Wed: Room ) Advanced DB Copyright by S.-g.

Chapter 3: Relational Model

S.Y.B.Sc. (CS) PAPER - III, Section - I Data Base Management Systems

CSE 562 Database Systems

High Level Database Models

CS403- Database Management Systems Solved Objective Midterm Papers For Preparation of Midterm Exam

Midterm Exam (Version B) CS 122A Spring 2017

Database Design Theory and Normalization. CS 377: Database Systems

Database System Concepts

Functional Dependencies and Finding a Minimal Cover

Advance Database Systems. Joining Concepts in Advanced SQL Lecture# 4

DBS 2006: 1 st week. DBS 2006: Plan. DB Life-Cycle: Requirement analysis. Data modelling: Conceptual Design. Logical Schema Design

CSE 544 Principles of Database Management Systems

Integrity Constraints and Functional Dependency

Relational Databases

Functional Dependencies and. Databases. 1 Informal Design Guidelines for Relational Databases. 4 General Normal Form Definitions (For Multiple Keys)

Relational Algebra. Mr. Prasad Sawant. MACS College. Mr.Prasad Sawant MACS College Pune

The Relational Model

Relational Algebra and SQL

FUNCTIONAL DEPENDENCIES

CSE 344 Midterm Nov 1st, 2017, 1:30-2:20

Set theory is a branch of mathematics that studies sets. Sets are a collection of objects.

Transcription:

QUIZ 1 REVIEW SESSION DATABASE MANAGEMENT SYSTEMS

SCHEMA DESIGN & RELATIONAL ALGEBRA A database schema is the skeleton structure that represents the logical view of the entire database Logical design of a relation: <relation_name>(<primary_key>, <attribute1>, <attribute2>,...) Example: employee(emp_id, first_name, last_name, age, date_of_hire) company( company_id, company_name, hq_location, num_employees)

RELATIONAL ALGEBRA It s basically procedural query language that takes instances of relations as input and yields relations as output Uses operators (unary / binary) to perform queries. Fundamental operations are as follows Select (σ) selects tuples that satisfy the given predicate Project (π) projects columns that satisfy the given predicate Union ( ) does a binary union between given relations: a b = { t t a or t b} Set difference ( ) outputs tuples present in first relation but not the second Cartesian product ( ) combines tuples of two relations into one relation Rename (ρ) renames output relation

RELATIONAL CALCULUS Tuple Relational Calculus: Notation - {T p(t)} Example: { t.name student(t) ^ t.course = cs127' } Returns tuples (with name ) from Student who take/have taken cs127 TRC can be quantified using existential ( ) or universal quantifiers ( ) e.g. { r t student(t.course = cs127' ^ r.name = t.name)} yields same output as TRC expression above

ER MODEL Defines the conceptual view of a database. Think of it as a framework for organizing and interpreting data Employs 3 basic concepts: entity sets set of entities(objects) of the same type that share the same properties(attributes) relationship sets set of associations(relationships) among entities attributes basically the properties of a given entity ER diagrams should be simple and clear

ER MODEL KEYS Attribute(s) that uniquely identify an entity in an entity set Super key set of attributes (one or more) that collectively identify an entity Candidate key minimal super key. NOTE entity set can have more than one candidate key Primary key candidate key chosen to uniquely identify the entity set RELATIONSHIPS Associations among entities e.g. region sells items, employee works at company, e.t.c. Number of participating relationships defines the degree of the relationship (binary (2), ternary (3), n-ary)

ER MODEL Cardinality - specifies how many instances of an entity relate to one instance of another entity. one-to-one - one entity from A can be associated with at most one entity of B and vice versa one-to-many - one entity from A can be associated with more than one entities of B. However, an entity from B, can be associated with at most one entity of A many-to-one - more than one entities from A can be associated with at most one entity of B. However an entity from B can be associated with more than one entity from A many-to-many - one entity from A can be associated with more than one entity from B and vice versa

ER DIAGRAM EXAMPLE

SQL Integrity Constraints Primary key: PRIMARY KEY(<attribute_name>, <attribute_name>, ) Primary key of a table; must be non-null and unique Foreign Key: FOREIGN KEY(<attribute_name>, <attribute_name>, ) REFERENCES <table_name> References the primary key of another relation non-null : <attr> NOT NULL Unique: <attr> UNIQUE All values must be unique (can include nulls) Also can do: UNIQUE(<attr1>, <attr2> )

SQL Different types of SQL JOINs ( (INNER) JOIN, LEFT (OUTER) JOIN, RIGHT (OUTER) JOIN, FULL (OUTER) JOIN) GROUP BY statement - used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or more columns HAVING clause - WHERE keyword cannot be used with aggregate functions AND, OR and NOT Operators ORDER BY Keyword

SQL employee(e_id, name, age, salary) works(e_id, d_id, hours_per_week) department(d_id, name, budget, manager_id) Find all the employees who work in either philosophy or history department SELECT e.* FROM employee e INNER JOIN ( SELECT w.e_id FROM works w INNER JOIN department d ON w.d_id = d.d_id WHERE d.dname IN ( philosophy', history') ) b ON e.eid = b.eid

FUNCTIONAL DEPENDENCIES A set of constraints between two attributes in a relation Represented by an arrow sign ( ): X Y, means X functionally determines Y If a functional dependency X Y holds, where Y is a subset of X, then it is called trivial. Trivial functional dependencies always hold. Closure (F + ) is the set of functional dependencies logically implied by F The canonical cover is a minimal set of dependencies C which imply every FD defined in the closure of F

ARMSTRONG'S AXIOMS Fundamental Rules (W, X, Y, Z: sets of attributes) Reflexivity If Y X then X Y Augmentation If X Y then WX WY Transitivity - If X Y and Y Z then X Z Additional Rules Union - If X Y and X Z, then X YZ Decomposition - If X YZ then X Y and X Z Pseudotransitivity - If X Y and WY Z, then WX Z

Closure Algorithm 1 Closure = S Loop For each F in S, apply reflexivity and augmentation rules Add the new FDs to the Closure For each pair of FDs in S, apply the transitivity rule Add the new Fd to Closure Until closure doesn't change any further

Closure Algorithm 2

Closure Example R=(A, B, C, D) F={A BC; C D}

{A}+ = {A, B, C, D} <--- Minimum candidate key {B}+ = {B} {C}+ = {C, D} {D}+ = {D} {A, B}+ = {A, B, C, D} <--- Superkey {A, C}+ = {A, B, C, D} <--- Superkey {B, C}+ = {B, C, D} {A, D}+ = {A, B, C, D} <--- Superkey {B, D}+ = {B, D} {C, D}+ = {C, D} {A, B, C}+ = {A, B, C, D} <--- Superkey {A, B, D}+ = {A, B, C, D} <--- Superkey {A, C, D}+ = {A, B, C, D} <--- Superkey {B, C, D}+ = {B, C, D} {A, B, C, D}+ = {A, B, C, D} <--- Superkey To practice: http://raymondcho.net/relationaldatabasetools/relationaldatabasetools

Canonical Cover A minimal set of dependencies C which imply every FD defined in the closure of F ALGORITHM canonical-cover(x: FD Set) BEGIN REPEAT UNTIL STABLE 1. Where possible, apply UNION rule (A s Axioms) 2. Remove all extraneous attributes: a. Test if B extraneous in A BC (B extraneous if (A B) (F {A BC} U {A C})+) = F+ b. Test if B extraneous in AB C (B extraneous if (A C) F+) END