The Relational Model
|
|
- Meghan Barton
- 6 years ago
- Views:
Transcription
1 The Relational Model
2 What is the Relational Model Relations Domain Constraints SQL Integrity Constraints Translating an ER diagram to the Relational Model and SQL Views
3
4 A relational database consists of a collection of tables Each table has a unique name Each row represents a single entity or relationship A table corresponds to the mathematical concept of a set Note that the definition of a relation* is not the same as the usual mathematical definition *per E.F. Codd Relations correspond to tables Tuples correspond to rows a relation is a set of tuples (d 1, d 2,..., d n ), where each element d j is a member of D j, a data domain
5 The key construct in the relational model is a relation A DB is a collection of relations Relations consist of a relation instance and a relation schema A relation instance corresponds to an actual table with a set of rows A relation schema consists of the column headings and domains of the table
6 A schema consists of The relation's name The name of each column in the table, also known as a field, or attribute The domain of each field Each domain has a set of associated values like a type For example, the Customer relation Customer = (sin, firstname, lastname, age, income) The schema also specifies the domain of each attribute
7 Relation schema: Customer = (sin, firstname, lastname, age, salary) sin firstname lastname age salary 111 Buffy Summers Xander Harris Relation instance 333 Rupert Giles Dawn Summers Each field (attribute) has a domain: char(11), char(20), char(20), integer, real An instance is a (small) subset of the Cartesian product of the domains
8 A domain of a field is similar to the type of a variable The values that can appear in a field are restricted to the field's domain A relation instance is a subset of the Cartesian product of the list of domains If a relation schema has domains D 1 to D n Where the domains are associated with fields f 1 to f n A relation must be a subset of D 1 D 2 D n-1 D n In practice a relation instance is usually some very small subset of the Cartesian product
9 A relation instance is a set of tuples, or records Each tuple has the same number of fields as the schema No two tuples are identical Relations are defined to be sets of unique tuples A set is a collection of distinct values In practice DBMS allow tables to have duplicate records in some circumstances The order of the tuples is not important
10 The degree of a relation is the number of fields Also referred to as arity The degree of the Customer relation is 5 The cardinality of a relation instance is the number of tuples it contains The cardinality of the Customer relation instance is 4 A relational database is a collection of relations with distinct relation names A relational database schema is the collection of schemas for all relations in the database
11 Relational model Relation schema Relation instances (relations) Fields Tuples Database Terminology Table schema Tables Columns or attributes Records or rows
12
13 SQL stands for Structured Query Language SQL is divided into two parts Data Manipulation Language (DML) which allows users to create, modify and query data Data Definition Language (DDL) which is used to define external and conceptual schemas The DDL supports the creation, deletion and modification of tables Including the specification of domain constraints and other constraints
14 To create a table use the CREATE TABLE statement Specify the table name, field names and domains CREATE TABLE Customer ( sin CHAR(11), firstname CHAR(20), lastname CHAR(20), age INTEGER, income REAL) Question is SQL case sensitive? Answer SQL keywords (create and table for example) are not case sensitive. Named objects (tables, columns etc.) may be.
15 To insert a record into an existing table use the INSERT statement The list of column names is optional If omitted the values must be in the same order as the columns INSERT INTO Customer(sin, firstname, lastname, age, income) VALUES ('111', 'Sam', 'Spade', 23, 65234)
16 To delete a record use the DELETE statement The WHERE clause specifies the record(s) to be deleted DELETE FROM Customer WHERE sin = '111' Be careful, the following SQL query deletes all the records in a table DELETE FROM Customer
17 Use the UPDATE statement to modify a record, or records, in a table Note that the WHERE statement is evaluated before the SET statement Like DELETE the WHERE clause specifies which records are to be updated UPDATE Customer SET age = 37 WHERE sin = '111'
18 To delete a table use the DROP TABLE statement This not only deletes all of the records but also deletes the table schema DROP TABLE Customer
19 Columns can be added or removed to tables using the ALTER TABLE statement ADD to add a column and DROP to remove a column ALTER TABLE Customer ADD height INTEGER ALTER TABLE Customer DROP height
20 An integrity constraint restricts the data that can be stored in a DB To prevent invalid data being added to the DB e.g. two people with the same SIN or someone with a negative age When a DB schema is defined, the associated integrity constraints should also be specified A DBMS checks every update to ensure that it does not violate any integrity constraints
21 Domain Constraints Specified when tables are created by selecting the type of the data e.g. age INTEGER Key Constraints Identifies primary keys and other candidate keys Foreign Key Constraints References primary keys of other tables General constraints
22 A key constraint states that a minimal subset of the fields in a relation is unique i.e. a candidate key SQL allows two sorts of key constraints The UNIQUE statement identifies candidate keys Records may not have duplicate values for the set of attributes specified in the UNIQUE statement A PRIMARY KEY identifies the primary key Records may not have duplicate primary keys and May not have null values for primary key attributes
23 A primary key identifies the unique set of attributes that will be used to identify a record in a table In some cases there are obvious primary keys in the problem domain (e.g. SIN) In other cases, a primary key may be generated by the system Candidate keys are identified to record the fact that a set of attributes should be unique Preventing duplicate data being entered into the table for this set of attributes
24 Assume that a patient can be uniquely identified by either SIN or MSP number SIN is chosen as the primary key CREATE TABLE Patient ( sin CHAR(11), msp CHAR(15), firstname CHAR(20), lastname CHAR(20), age INTEGER, ) CONSTRAINT unique_msp UNIQUE (msp) PRIMARY KEY (sin) )
25 Consider the abbreviated ERD shown below Takes is a many-to-many relationship, so a database table must be created for it (more on this later) It makes no sense for the Takes table to be allowed to contain the student ID of students who do not exist The student ID in Takes should be identified as a foreign key, that references Student Student takes Course
26 A foreign key constraint references the primary key of another relation The value of the foreign key attribute(s) must match a primary key in the referenced table referenced relation Student Takes referencing relation Course
27 The attributes of the foreign key and the referenced primary key must be consistent The same number of attributes, with Compatible attribute types, but The attribute names may be different A foreign key references the entire primary key Where the primary key is compound the foreign key must also be compound And not multiple single attribute foreign keys
28 Customer owns an account must be owned by a single customer Account CREATE TABLE Account( accountnumber INTEGER, type CHAR(5), balance REAL, custsin CHAR(11), PRIMARY KEY (accountnumber)) (accountnumber), CONSTRAINT fk_customer FOREIGN KEY (custsin) REFERENCES Customer )
29 A DB may require constraints other than primary keys, foreign keys and domain constraints Limiting domain values to subsets of the domain e.g. limit grade to the set of legal grades Or other constraints involving multiple attributes SQL supports two kinds of general constraint Table constraints associated with a single table Assertions which may involve several tables and are checked when any of these tables are modified These will be covered later in the course
30 Whenever a table with a constraint is modified the constraint must be checked A modification can be a deletion, a change (update) or an insertion of a record If a transaction violates a constraint what happens? Primary key constraints A primary key constraint can be violated in two ways A record can be changed or inserted so that it duplicates the primary key of another record in the table or A record can be changed or inserted so that (one of) the primary key attribute(s) is null In either case the transaction is rejected
31 Consider these schema (the domains have been omitted for brevity) Customer = (sin, firstname, lastname, age, income) Account = (accountnumber, balance, type, sin) sin in Account is a foreign key referencing Customer age income sin accountnumber balance Customer owns Account lastname firstname type
32 number balance type sin CHQ CHQ CHQ SAV 333 sin first last age salary 111 Buffy Summers Xander Harris Rupert Giles Dawn Summers Inserting {409, 0, CHQ, 555} into Account violates the foreign key on sin as there is no sin 555 in Customer The insertion is rejected To process the insertion a Customer with a sin of 555 must first be inserted into the Customer table
33 number balance type sin CHQ CHQ CHQ SAV 333 Changing this record s sin to 555 violates the foreign key, again leading to the transaction being rejected sin first last age salary 111 Buffy Summers Xander Harris Rupert Giles Dawn Summers
34 number balance type sin CHQ CHQ CHQ SAV 333 sin first last age salary 111 Buffy Summers Xander Harris Rupert Giles Dawn Summers Deleting Buffy violates the foreign key, because a record with that sin exists in the Account table
35 number balance type sin CHQ CHQ CHQ SAV 333 sin first last age salary 111 Buffy Summers Xander Harris Rupert Giles Dawn Summers Updating Buffy's sin to 666 also violates the foreign key, because a record with the old sin is in the Account table
36 A deletion or update transaction in the referenced table may violate a foreign key Different responses can be specified in SQL Reject the transaction (the default) NO ACTION Delete or update the referencing record CASCADE Set the referencing record's foreign key attribute(s) to null (only on deletion) SET NULL Set the referencing record's foreign key attribute(s) to a default value (only on deletion) SET DEFAULT The default value must be specified in the foreign key
37
38 The ER model is a high level design which can be translated into a relational schema And therefore into SQL Each entity and relationship set can be represented by a unique relation Rows in an entity set table represent unique entities Rows in a relationship set table represent associations between entities Some relationship sets do not need to be represented by separate relations SQL constraints should be created to represent constraints identified in the ERD
39 A table that represents an entity set should have the following characteristics One column for each attribute The domain of each attribute should be known and specified in the table The primary key should be specified in the table Other constraints that have been identified outside the ER model should also be created where possible
40 age income sin Customer lastname firstname CREATE TABLE Customer ( sin CHAR(11), firstname CHAR(20), lastname CHAR(20), age INTEGER, income REAL, PRIMARY KEY (sin) )
41 The attributes of a relationship set are The primary keys of the participating entity sets, and Any descriptive attributes of the relationship set The mapping cardinalities of the entities involved in a relationship determine The primary key of the relationship set and Whether or not the relationship set needs to be represented as a separate table Foreign keys should be created for the attributes derived from the participating entity sets
42 CREATE TABLE WorksIn ( sin CHAR(11), branchname CHAR(30), startdate DATETIME, FOREIGN KEY (sin) REFERENCES Employee, FOREIGN KEY (branchname) REFERENCES Branch, PRIMARY KEY (sin, branchname) ) name salary Employee sin startdate worksin branchname budget Branch city
43 A separate table is required to represent a relationship set with no cardinality constraints i.e. relationships that are many to many The primary key of the relationship set is the union of the attributes derived from its entity sets A compound key made up of the primary keys of the participating entity sets Attributes derived from its entity sets should be declared as foreign keys
44 CREATE TABLE Manages ( managersin CHAR(11), subordinatesin CHAR(11), FOREIGN KEY (managersin) REFERENCES Employee, FOREIGN KEY (subordinatesin) REFERENCES Employee, PRIMARY KEY (managersin, subordinatesin) ) salary firstname sin lastname manager subordinate manages Employee
45 Determine attributes for the table as for a relationship set without cardinality constraints To determine the primary key of a binary relationship set If the relationship is one to one then the primary key of either entity set can be its primary key But it must be only one of the two primary keys If the relationship is many to one, or one to many the primary key of the many entity set is its primary key That is, the entity set whose entities can only appear once in the relationship set; the entity set with the key constraint
46 If the relationship set has no cardinality constraints the primary key is a compound key Union of the primary keys of the participating entity sets If the relationship set has at least one cardinality constraint The primary key is taken from one of the entity sets with a many relationship That is, one of the entity sets whose entities can be involved in at most one relationship
47 A binary relationship does not require a table if at least one its entities has a key constraint Add the relationship set's attributes to the table for the entity set that provided the primary key If the entity s participation in the relationship is partial, some rows may not have data for these attributes Such rows will contain null for these fields, which wastes space, and has other undesirable properties The attributes from the other entity sets involved in the relationship are specified as foreign keys
48 CREATE TABLE Employee ( sin CHAR(11), name CHAR(40), salary REAL, branchname CHAR(30), startdate DATETIME, FOREIGN KEY (branchname) REFERENCES Branch, PRIMARY KEY (sin) ) startdate salary sin name Employee worksin Since an employee can only work in one branch there is still only one row for each employee in the Employee table No table is created for the worksin relationship branchname budget Branch address
49 Where possible participation constraints should be included in a table specification By declaring the attributes on which there is a foreign key as NOT NULL This approach only works when a relationship set is not represented in a separate table i.e. when the relationship is represented as a foreign key in a table that represents an entity set Specifying an attribute as NOT NULL forces every record of that entity set to have a value for the attribute Some participation constraints must be modeled using assertions, triggers or other methods
50 CREATE TABLE Owns ( sin CHAR(11), accountnumber INTEGER, FOREIGN KEY (sin) REFERENCES Customer, FOREIGN KEY (accountnumber) REFERENCES Account, PRIMARY KEY (sin, accountnumber) ) sin and accountnumber cannot be null but the participation constraint is not represented Why not? birthdate income sin lastname firstname accountnumber type balance Customer owns Account
51 CREATE TABLE Employee ( sin CHAR(11), name CHAR(40), salary REAL, Making branchname NOT NULL ensures that every Employee must branchname CHAR(30) NOT NULL, work in a branch startdate DATETIME, FOREIGN KEY (branchname) REFERENCES Branch, PRIMARY KEY (sin) ) name salary Employee sin startdate worksin branchname budget Branch address
52 CREATE TABLE WorksIn ( sin CHAR(11), branchid INTEGER, from DATETIME, to DATETIME, FOREIGN KEY (sin) REFERENCES Employee, FOREIGN KEY (branchid) REFERENCES Branch, PRIMARY KEY (sin, branchid, from, to) ) from Note that a table is not required for Duration as it would be redundant All durations must appear in worksin and Duration only has primary key attributes to salary sin lastname firstname Duration budget branchid branchname Employee worksin Branch
53 This ERD requires the following tables Account with NOT NULL foreign key, sin, references Customer and represents Owns birthdate income sin lastname firstname accountnumber type balance Customer owns Account Customer, with foreign key empsin to represent PersonalBanker And an Employee table personal banker name salary Employee sin
54 A weak entity set has the following characteristics Total participation in the identifying relationship A cardinality constraint with the identifying relationship A partial key Therefore the weak entity set should: Include a foreign key (to its owner entity set), the attributes of which are part of the WES' primary key Which prevents these attributes from being null Usually specify the foreign key as ON DELETE CASCADE
55 CREATE TABLE Room ( name CHAR(10), squarefeet REAL, taxnumber INTEGER, PRIMARY KEY (name, taxnumber), FOREIGN KEY (taxnumber) REFERENCES Building ON DELETE CASCADE) city street number taxnumber squarefeet name House contains Room
56 There are two basic approaches to translating class hierarchies to tables Create separate tables for the superclass and for each subclass The superclass table only contains attributes of the superclass entity The subclass tables contain their own attributes, and the primary key attributes of the superclass Superclass attributes are declared as both the primary key and a foreign key in the subclasses Cascade deletion of superclass records to subclasses Or
57 Create tables for the subclasses only The subclass tables contain their attributes, and all of the attributes of the superclass The primary key of the subclass is the primary key of the superclass This assumes that there are no entities in the superclass that are not entities in a subclass i.e. That a coverage constraint exists Otherwise coverage and overlap constraints must be specified using assertions
58 Building = (taxnumber, city, street, number, tax) and RentalProperty = (taxnumber FK, units, rate) HeritageBuilding = (taxnumber FK, buildyear) city taxnumber street number tax Building units rate ISA buildyear RentalProperty HeritageBuilding
59 RentalProperty = (taxnumber, city, street, number, tax, units, rate) and HeritageBuilding = (taxnumber, city, street, number, tax, buildyear) taxnumber city number street tax Building units rate ISA buildyear RentalProperty HeritageBuilding
60 An aggregate entity is represented by the table defining the relationship set in the aggregation The relationship set between the aggregate entity and the other entity has the following attributes: The primary key of the participating entity set, and The primary key of the relationship set that defines the aggregate entity, and Its own descriptive attributes, if any The normal rules for determining primary keys and omitting tables apply
61 Create tables for the entity sets Project Department Employee And the relationship sets sponsors monitors monitors In this example, each department, project pair is monitored by an employee Employee Department sponsors Project
62 There is a case where no table is required for an aggregate entity Even where there are no cardinality constraints If there is total participation between the aggregate entity and its relationship, and If the aggregate entity does not have any descriptive attributes Insert the attributes of the aggregate entity into the table representing the relationship with that entity
63 A project, department pair must be monitored by an employee, so each such pair must appear in monitors If sponsors has no descriptive attributes, create a monitors table with the primary keys of Employee, Project and Department monitors Create tables for the entity sets Project Department Employee Employee Department sponsors Project
64 Views are not explicitly stored in a DB but are created as required from a view definition At least conceptually, if not necessarily in practice Once defined, views may be referred to in the same way as a tables View are useful for Convenience users can access the data they require without referring to many tables Security users can only access appropriate data Independence views can help mask changes in the conceptual schema
65 Consider a DB containing these two tables: Branch =(branchname, managersin, budget) Employee = (sin, name, salary, birthdate, branchname) Where branchname in Employee is a foreign key A view is needed to access the employee's SIN, name and manager s SIN CREATE VIEW Emp_Manager (E.sin, E.name, B.managerSIN) AS SELECT E.sin, E.name, B.managerSIN FROM Branch B Employee E WHERE B.branchName = E.branchName
66 Users should be able to interact with views as if they were base tables And without being aware of the distinction This goal is achieved when running queries on views However updates to views may cause problems Particularly if a view is derived from multiple tables and does not include the primary keys of all tables Generally, updates are only allowed on views derived from a single table And, even then, there are further restrictions
67
68 Two distinct tuples in a relation instance, cannot have identical values in all the fields of a superkey Or if two entities have the same superkey values, they must have the same values for their other attributes So must, in fact, be the same entity We can describe this idea formally in this way A subset K of a relation R is a superkey of R if for all pairs of tuples t 1 and t 2 t 1 t 2 then t 1 [K] t 2 [K] That is, where K is a set of attributes of a relation R K is a superkey for R if for all pairs of different tuples there are no two tuples with the same values for K
69 The notion of a superkey can be generalized and applied to smaller sets of attributes e.g. Vehicle = {vin, colour, model, capacity} vin (vehicle identification number) is a superkey We can say that capacity is functionally determined by vin as there can only be one capacity for a particular vin The model and the capacity have the same relationship A particular model can only have one capacity However, unlike the vin, the model does not functionally determine the colour We call this relationship functional dependency
70 Denote functional dependencies as follows If R is a relation and if R and R we can express a functional dependency as holds on R if for all pairs of tuples such that t 1 [ ] = t 2 [ ] then t 1 [ ] = t 2 [ ] A subset K of a relation R is a superkey if K R In the vehicle example vin {vin, colour, model, capacity} model {capacity} means subset, proper subset
71 Why use functional dependencies? To specify constraints on relations To determine if a relation is legal given a set of functional dependencies To reason about whether or not the set of tables in a database is appropriate We will use functional dependencies to decompose tables into normal forms We will discuss functional dependencies in more detail later in the course
Relational Model. Topics. Relational Model. Why Study the Relational Model? Linda Wu (CMPT )
Topics Relational Model Linda Wu Relational model SQL language Integrity constraints ER to relational Views (CMPT 354 2004-2) Chapter 3 CMPT 354 2004-2 2 Why Study the Relational Model? Most widely used
More informationThe Relational Model
The Relational Model UVic C SC 370, Fall 2002 Daniel M. German Department of Computer Science University of Victoria September 25, 2002 Version: 1.03 3 1 The Relational Model (1.03) CSC 370 dmgerman@uvic.ca
More informationDatabase Applications (15-415)
Database Applications (15-415) The Relational Model Lecture 3, January 18, 2015 Mohammad Hammoud Today Last Session: The entity relationship (ER) model Today s Session: ER model (Cont d): conceptual design
More informationThe Relational Model
The Relational Model UVic C SC 370, Fall 2002 Daniel M. German Department of Computer Science University of Victoria 3 1 The Relational Model CSC 370 dmgerman@uvic.ca Overview How is data represented in
More informationThe Relational Model. Why Study the Relational Model? Relational Database: Definitions
The Relational Model Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Microsoft, Oracle, Sybase, etc. Legacy systems in
More informationThe Relational Model. Chapter 3. Comp 521 Files and Databases Fall
The Relational Model Chapter 3 Comp 521 Files and Databases Fall 2012 1 Why Study the Relational Model? Most widely used model by industry. IBM, Informix, Microsoft, Oracle, Sybase, etc. It is simple,
More informationThe Relational Model. Roadmap. Relational Database: Definitions. Why Study the Relational Model? Relational database: a set of relations
The Relational Model CMU SCS 15-415/615 C. Faloutsos A. Pavlo Lecture #3 R & G, Chap. 3 Roadmap Introduction Integrity constraints (IC) Enforcing IC Querying Relational Data ER to tables Intro to Views
More informationThe Relational Model. Outline. Why Study the Relational Model? Faloutsos SCS object-relational model
The Relational Model CMU SCS 15-415 C. Faloutsos Lecture #3 R & G, Chap. 3 Outline Introduction Integrity constraints (IC) Enforcing IC Querying Relational Data ER to tables Intro to Views Destroying/altering
More informationConstraints. Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers. John Edgar 2
CMPT 354 Constraints Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers John Edgar 2 firstname type balance city customerid lastname accnumber rate branchname phone
More informationEGCI 321: Database Systems. Dr. Tanasanee Phienthrakul
1 EGCI 321: Database Systems Dr. Tanasanee Phienthrakul 2 Chapter 10 Data Definition Language (DDL) 3 Basic SQL SQL language Considered one of the major reasons for the commercial success of relational
More informationCSE 530A. ER Model to Relational Schema. Washington University Fall 2013
CSE 530A ER Model to Relational Schema Washington University Fall 2013 Relational Model A relational database consists of a group of relations (a.k.a., tables) A relation (table) is a set of tuples (rows)
More informationRelational Databases BORROWED WITH MINOR ADAPTATION FROM PROF. CHRISTOS FALOUTSOS, CMU /615
Relational Databases BORROWED WITH MINOR ADAPTATION FROM PROF. CHRISTOS FALOUTSOS, CMU 15-415/615 Roadmap 3 Introduction Integrity constraints (IC) Enforcing IC Querying Relational Data ER to tables Intro
More informationIntroduction Relational Algebra Operations
CMPT 354 Introduction Relational Algebra Operations Projection and Selection Set Operations Joins Division Tuple Relational Calculus John Edgar 2 Query languages allow the manipulation and retrieval of
More informationData Modeling. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke
Data Modeling Yanlei Diao UMass Amherst Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 Outline v Conceptual Design: ER Model v Relational Model v Logical Design: from ER to Relational 2 Conceptual
More informationThe Relational Model. Chapter 3
The Relational Model Chapter 3 Why Study the Relational Model? Most widely used model. Systems: IBM DB2, Informix, Microsoft (Access and SQL Server), Oracle, Sybase, MySQL, etc. Legacy systems in older
More informationThe Relational Model. Chapter 3. Database Management Systems, R. Ramakrishnan and J. Gehrke 1
The Relational Model Chapter 3 Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc.
More informationThe Relational Model 2. Week 3
The Relational Model 2 Week 3 1 We have seen how to create a database schema, how do we create an actual database on our computers? professor(pid : string, name : string) course(pid : string, number :
More informationChapter 4. The Relational Model
Chapter 4 The Relational Model Chapter 4 - Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations and relations in the relational model.
More informationThe Relational Model. Chapter 3. Comp 521 Files and Databases Fall
The Relational Model Chapter 3 Comp 521 Files and Databases Fall 2014 1 Why the Relational Model? Most widely used model by industry. IBM, Informix, Microsoft, Oracle, Sybase, MySQL, Postgres, Sqlite,
More informationIntroduction to Databases
Introduction to Databases Data Retrival SELECT * FROM Students S WHERE S.age < 18 Data Retrival SELECT S.name, S.login FROM Students S WHERE S.age < 18 Entity sets to tables Entity sets to tables CREATE
More informationDatabase Management Systems. Chapter 3 Part 2
Database Management Systems Chapter 3 Part 2 The Relational Model Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Logical DB Design: ER to Relational Entity sets to tables: CREATE TABLE
More informationCMPT 354: Database System I. Lecture 2. Relational Model
CMPT 354: Database System I Lecture 2. Relational Model 1 Outline An overview of data models Basics of the Relational Model Define a relational schema in SQL 2 Outline An overview of data models Basics
More informationThe Entity-Relationship Model. Overview of Database Design
The Entity-Relationship Model Chapter 2, Chapter 3 (3.5 only) Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Overview of Database Design Conceptual design: (ER Model is used at this stage.)
More informationIntroduction to Data Management. Lecture #4 (E-R Relational Translation)
Introduction to Data Management Lecture #4 (E-R Relational Translation) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v Today
More informationDatabase Systems. Course Administration
Database Systems ( ) September 20, 2004 Lecture #2 By Hao-hua Chu ( ) 1 Course Administration Can everyone get the textbook? HW #1 is out on the course homepage It is due one week from today. Next week
More informationHigh-Level Database Models (ii)
ICS 321 Spring 2011 High-Level Database Models (ii) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1 Logical DB Design: ER to Relational Entity sets to
More informationDatabase Systems ( 資料庫系統 )
Database Systems ( 資料庫系統 ) 9.28.2011 Lecture #3 1 Course Administration Please download HW #1 from course homepage It is due 10/12/2011. This lecture: R&G Chapter 3 Next week reading: R&G Chapter 41~ 4.1
More informationData about data is database Select correct option: True False Partially True None of the Above
Within a table, each primary key value. is a minimal super key is always the first field in each table must be numeric must be unique Foreign Key is A field in a table that matches a key field in another
More informationRelational Data Model
Relational Data Model 1. Relational data model Information models try to put the real-world information complexity in a framework that can be easily understood. Data models must capture data structure
More informationPart I: Structured Data
Inf1-DA 2011 2012 I: 24 / 117 Part I Structured Data Data Representation: I.1 The entity-relationship (ER) data model I.2 The relational model Data Manipulation: I.3 Relational algebra I.4 Tuple relational
More informationHigh Level Database Models
ICS 321 Fall 2011 High Level Database Models Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 9/21/2011 Lipyeow Lim -- University of Hawaii at Manoa 1 Database
More informationDatabase Applications (15-415)
Database Applications (15-415) ER to Relational & Relational Algebra Lecture 4, January 20, 2015 Mohammad Hammoud Today Last Session: The relational model Today s Session: ER to relational Relational algebra
More informationACS-3902 Fall Ron McFadyen 3D21 Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition)
ACS-3902 Fall 2016 Ron McFadyen 3D21 ron.mcfadyen@acs.uwinnipeg.ca Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition) 1 The Relational Data Model and Relational Database Constraints
More informationThe Entity-Relationship Model
The Entity-Relationship Model Chapter 2 Instructor: Vladimir Zadorozhny vladimir@sis.pitt.edu Information Science Program School of Information Sciences, University of Pittsburgh 1 Database: a Set of Relations
More informationDATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM For COMPUTER SCIENCE DATABASE MANAGEMENT. SYSTEM SYLLABUS ER model. Relational model: relational algebra, tuple calculus, SQL. Integrity constraints, normal forms. File organization,
More informationIntroduction to Data Management. Lecture #4 (E-R à Relational Design)
Introduction to Data Management Lecture #4 (E-R à Relational Design) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v Reminders:
More informationWhy Study the Relational Model? The Relational Model. Relational Database: Definitions. The SQL Query Language. Relational Query Languages
Why Study the Relational Model? The Relational Model Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. Legacy systems in older models E.G., IBM s IMS Recent competitor: object-oriented
More information8) A top-to-bottom relationship among the items in a database is established by a
MULTIPLE CHOICE QUESTIONS IN DBMS (unit-1 to unit-4) 1) ER model is used in phase a) conceptual database b) schema refinement c) physical refinement d) applications and security 2) The ER model is relevant
More informationFrom ER to Relational Model. Book Chapter 3 (part 2 )
From ER to Relational Model Book Chapter 3 (part 2 ) Logical DB Design: ER to Relational Translate Entity sets to tables: ssn name Employees lot CREATE TABLE Employees (ssn CHAR(11), name CHAR(20), lot
More informationDatabase Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra
Database Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra Relational Data Model and Relational Constraints Part 1 A simplified diagram to illustrate the main
More informationCONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL
RELATIONAL MODEL TO Data Model CONCEPTUAL DESIGN: ER TO RELATIONAL TO How to represent Entity sets, Relationship sets, Attributes, Key and participation constraints, Subclasses, Weak entity sets...? 2
More informationOverview of db design Requirement analysis Data to be stored Applications to be built Operations (most frequent) subject to performance requirement
ITCS 3160 Data Base Design and Implementation Jing Yang 2010 Fall Class 12: Data Modeling Using the Entity-Relationship (ER) Model Overview of db design Requirement analysis Data to be stored Applications
More informationCOSC344 Database Theory and Applications. σ a= c (P) Lecture 3 The Relational Data. Model. π A, COSC344 Lecture 3 1
COSC344 Database Theory and Applications σ a= c (P) S P Lecture 3 The Relational Data π A, C (H) Model COSC344 Lecture 3 1 Overview Last Lecture Database design ER modelling This Lecture Relational model
More informationSQL DDL. CS3 Database Systems Weeks 4-5 SQL DDL Database design. Key Constraints. Inclusion Constraints
SQL DDL CS3 Database Systems Weeks 4-5 SQL DDL Database design In its simplest use, SQL s Data Definition Language (DDL) provides a name and a type for each column of a table. CREATE TABLE Hikers ( HId
More informationCOMP Instructor: Dimitris Papadias WWW page:
COMP 5311 Instructor: Dimitris Papadias WWW page: http://www.cse.ust.hk/~dimitris/5311/5311.html Textbook Database System Concepts, A. Silberschatz, H. Korth, and S. Sudarshan. Reference Database Management
More informationOVERVIEW OF DATABASE DEVELOPMENT
DATABASE SYSTEMS I WEEK 2: THE ENTITY-RELATIONSHIP MODEL OVERVIEW OF DATABASE DEVELOPMENT Requirements Analysis / Ideas High-Level Database Design Conceptual Database Design / Relational Database Schema
More informationCIS 330: Applied Database Systems. ER to Relational Relational Algebra
CIS 330: Applied Database Systems ER to Relational Relational Algebra 1 Logical DB Design: ER to Relational Entity sets to tables: ssn name Employees lot CREATE TABLE Employees (ssn CHAR(11), name CHAR(20),
More informationBasant Group of Institution
Basant Group of Institution Visual Basic 6.0 Objective Question Q.1 In the relational modes, cardinality is termed as: (A) Number of tuples. (B) Number of attributes. (C) Number of tables. (D) Number of
More informationCS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13
CS121 MIDTERM REVIEW CS121: Relational Databases Fall 2017 Lecture 13 2 Before We Start Midterm Overview 3 6 hours, multiple sittings Open book, open notes, open lecture slides No collaboration Possible
More informationMahathma Gandhi University
Mahathma Gandhi University BSc Computer science III Semester BCS 303 OBJECTIVE TYPE QUESTIONS Choose the correct or best alternative in the following: Q.1 In the relational modes, cardinality is termed
More informationThe Relational Model. Week 2
The Relational Model Week 2 1 Relations A relation is a more concrete construction, of something we have seen before, the ER diagram. name S.S.N students street city A relation is (just!) a table! We will
More informationER Model. Objectives (2/2) Electricite Du Laos (EDL) Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 1
ER Model Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Dept of Computer Engineering Khon Kaen University Objectives (1/2) Relational Data Model Terminology of relational data model How
More informationChapter 1: Introduction
Chapter 1: Introduction Chapter 2: Intro. To the Relational Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Database Management System (DBMS) DBMS is Collection of
More informationRelational Model. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan
Relational Model DCS COMSATS Institute of Information Technology Rab Nawaz Jadoon Assistant Professor COMSATS IIT, Abbottabad Pakistan Management Information Systems (MIS) Relational Model Relational Data
More informationRelational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity
COS 597A: Principles of Database and Information Systems Relational model continued Understanding how to use the relational model 1 with as weak entity folded into folded into branches: (br_, librarian,
More informationCS317 File and Database Systems
CS317 File and Database Systems Lecture 3 Relational Model & Languages Part-1 September 7, 2018 Sam Siewert More Embedded Systems Summer - Analog, Digital, Firmware, Software Reasons to Consider Catch
More informationSimple queries Set operations Aggregate operators Null values Joins Query Optimization. John Edgar 2
CMPT 354 Simple queries Set operations Aggregate operators Null values Joins Query Optimization John Edgar 2 Data Manipulation Language (DML) to Write queries Insert, delete and modify records Data Definition
More informationComp 5311 Database Management Systems. 4b. Structured Query Language 3
Comp 5311 Database Management Systems 4b. Structured Query Language 3 1 SQL as Data Definition Language Creates the Students relation. The type (domain) of each field is specified, and enforced by the
More information0. Database Systems 1.1 Introduction to DBMS Information is one of the most valuable resources in this information age! How do we effectively and efficiently manage this information? - How does Wal-Mart
More informationCIS 330: Applied Database Systems
1 CIS 330: Applied Database Systems Lecture 3: Introduction to ER Modeling The Relational Model Johannes Gehrke johannes@cs.cornell.edu http://www.cs.cornell.edu/johannes Announcements How many laptops
More informationThe DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.
Managing Data Data storage tool must provide the following features: Data definition (data structuring) Data entry (to add new data) Data editing (to change existing data) Querying (a means of extracting
More informationWhere Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams
Where Are We? Introduction to Data Management CSE 344 Lecture 15: Constraints We know quite a bit about using a DBMS Start with real-world problem, design ER diagram From ER diagram to relations -> conceptual
More informationContents. Database. Information Policy. C03. Entity Relationship Model WKU-IP-C03 Database / Entity Relationship Model
Information Policy Database C03. Entity Relationship Model Code: 164323-03 Course: Information Policy Period: Spring 2013 Professor: Sync Sangwon Lee, Ph. D 1 Contents 01. Overview of Database Design 02.
More informationRelational Database Systems Part 01. Karine Reis Ferreira
Relational Database Systems Part 01 Karine Reis Ferreira karine@dpi.inpe.br Aula da disciplina Computação Aplicada I (CAP 241) 2016 Database System Database: is a collection of related data. represents
More informationCSIT5300: Advanced Database Systems
CSIT5300: Advanced Database Systems L02: Relational Data Model Dr. Kenneth LEUNG Department of Computer Science and Engineering The Hong Kong University of Science and Technology Hong Kong SAR, China kwtleung@cse.ust.hk
More informationIntroduction to Relational Databases. Introduction to Relational Databases cont: Introduction to Relational Databases cont: Relational Data structure
Databases databases Terminology of relational model Properties of database relations. Relational Keys. Meaning of entity integrity and referential integrity. Purpose and advantages of views. The relational
More informationSQL (Structured Query Language)
Lecture Note #4 COSC4820/5820 Database Systems Department of Computer Science University of Wyoming Byunggu Yu, 02/13/2001 SQL (Structured Query Language) 1. Schema Creation/Modification: DDL (Data Definition
More informationIntroduction to Data Management. Lecture #5 Relational Model (Cont.) & E-Rà Relational Mapping
Introduction to Data Management Lecture #5 Relational Model (Cont.) & E-Rà Relational Mapping Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1
More informationRelational Data Model. Christopher Simpkins
Relational Data Model Christopher Simpkins 1 / 22 Relational Data Model A relation schema R(A a,..., A n ) is a relation name R and a list of attributes A 1,..., A n. Each attribute A i is the name of
More informationITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION
ITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION JING YANG 2010 FALL Class 3: The Relational Data Model and Relational Database Constraints Outline 2 The Relational Data Model and Relational Database Constraints
More informationRunning Example Tables name location
Running Example Pubs-Drinkers-DB: The data structures of the relational model Attributes and domains Relation schemas and database schemas databases Pubs (name, location) Drinkers (name, location) Sells
More informationNorthern India Engineering College, New Delhi Question Bank Database Management System. B. Tech. Mechanical & Automation Engineering V Semester
1. List four significant differences between a file-processing system and a DBMS. 2. Explain the difference between physical and logical data independence. 3. What are five main functions of a database
More informationConceptual Design. The Entity-Relationship (ER) Model
Conceptual Design. The Entity-Relationship (ER) Model CS430/630 Lecture 12 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Database Design Overview Conceptual design The Entity-Relationship
More informationKing Fahd University of Petroleum and Minerals
1 King Fahd University of Petroleum and Minerals Information and Computer Science Department ICS 334: Database Systems Semester 041 Major Exam 1 18% ID: Name: Section: Grades Section Max Scored A 5 B 25
More informationCMPT 354: Database System I. Lecture 5. Relational Algebra
CMPT 354: Database System I Lecture 5. Relational Algebra 1 What have we learned Lec 1. DatabaseHistory Lec 2. Relational Model Lec 3-4. SQL 2 Why Relational Algebra matter? An essential topic to understand
More informationThe Entity-Relationship Model. Steps in Database Design
The Entity-Relationship Model Steps in Database Design 1) Requirement Analysis Identify the data that needs to be stored data requirements Identify the operations that need to be executed on the data functional
More informationChapter 9: Relational DB Design byer/eer to Relational Mapping Relational Database Design Using ER-to- Relational Mapping Mapping EER Model
Chapter 9: Relational DB Design byer/eer to Relational Mapping Relational Database Design Using ER-to- Relational Mapping Mapping EER Model Constructs to Relations Relational Database Design by ER- and
More informationThe Relational Model Constraints and SQL DDL
The Relational Model Constraints and SQL DDL Week 2-3 Weeks 2-3 MIE253-Consens 1 Schedule Week Date Lecture Topic 1 Jan 9 Introduction to Data Management 2 Jan 16 The Relational Model 3 Jan. 23 Constraints
More information1. Considering functional dependency, one in which removal from some attributes must affect dependency is called
Q.1 Short Questions Marks 1. Considering functional dependency, one in which removal from some attributes must affect dependency is called 01 A. full functional dependency B. partial dependency C. prime
More informationRelational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions.
COSC 304 Introduction to Database Systems Relational Model and Algebra Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was
More informationMIS Database Systems Entity-Relationship Model.
MIS 335 - Database Systems Entity-Relationship Model http://www.mis.boun.edu.tr/durahim/ Ahmet Onur Durahim Learning Objectives Database Design Main concepts in the ER model? ER Diagrams Database Design
More informationIntroduction to Database Design
Introduction to Database Design UVic C SC 370 Daniel M German Introduction to Database Design (1.2.0) CSC 370 4/5/2005 14:52 p.1/33 Overview What are the steps in designing a database? What is the entity-relationship
More informationThe Entity-Relationship Model
The Entity-Relationship Model Chapter 2 Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Overview of Database Design Conceptual design: (ER Model is used at this stage.) What are the entities
More informationUnit I. By Prof.Sushila Aghav MIT
Unit I By Prof.Sushila Aghav MIT Introduction The Need for Databases Data Models Relational Databases Database Design Storage Manager Query Processing Transaction Manager DBMS Applications DBMS contains
More informationChapter 1 SQL and Data
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
More informationReview The Big Picture
CS445 - Introduction to Database Management Systems Fall Semester 2015 LECTURE 6 The Entity-Relationship Model Introduction TEXTBOOK REFERENCE: CHAPTERS 2,3 R&G 1 Review The Big Picture Data Modeling Relational
More informationThe Relational Model of Data (ii)
ICS 321 Fall 2013 The Relational Model of Data (ii) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1 Defining Relational Schema in SQL Two aspects: Data
More informationCS275 Intro to Databases
CS275 Intro to Databases The Relational Data Model Chap. 3 How Is Data Retrieved and Manipulated? Queries Data manipulation language (DML) Retrieval Add Delete Update An Example UNIVERSITY database Information
More informationRelational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity
COSC 416 NoSQL Databases Relational Model (Review) Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was proposed by E. F. Codd
More informationLAB 3 Notes. Codd proposed the relational model in 70 Main advantage of Relational Model : Simple representation (relationstables(row,
LAB 3 Notes The Relational Model Chapter 3 In the previous lab we discussed the Conceptual Database Design Phase and the ER Diagram. Today we will mainly discuss how to convert an ER model into the Relational
More informationChapter 6: Entity-Relationship Model
Chapter 6: Entity-Relationship Model Database System Concepts, 5th Ed. See www.db-book.com for conditions on re-use Chapter 6: Entity-Relationship Model Design Process Modeling Constraints E-R Diagram
More informationDatabase Design. ER Model. Overview. Introduction to Database Design. UVic C SC 370. Database design can be divided in six major steps:
Database Design Database design can be divided in six major steps: Requirements analysis Conceptual Database design (mostly done using the ER model) Logical Database design Schema refinement Physical Database
More informationDATABASE TECHNOLOGY - 1MB025 (also 1DL029, 1DL300+1DL400)
1 DATABASE TECHNOLOGY - 1MB025 (also 1DL029, 1DL300+1DL400) Spring 2008 An introductury course on database systems http://user.it.uu.se/~udbl/dbt-vt2008/ alt. http://www.it.uu.se/edu/course/homepage/dbastekn/vt08/
More informationDATABASE TECHNOLOGY - 1DL124
1 DATABASE TECHNOLOGY - 1DL124 Summer 2007 An introductury course on database systems http://user.it.uu.se/~udbl/dbt-sommar07/ alt. http://www.it.uu.se/edu/course/homepage/dbdesign/st07/ Kjell Orsborn
More informationCSE 530A. ER Model. Washington University Fall 2013
CSE 530A ER Model Washington University Fall 2013 Database Design Requirements Analysis Conceptual Database Design Creates an abstract model Logical Database Design Converts abstract model to concrete
More informationThe Entity Relationship Model
The Entity Relationship Model CPS352: Database Systems Simon Miner Gordon College Last Revised: 2/4/15 Agenda Check-in Introduction to Course Database Environment (db2) SQL Group Exercises The Entity Relationship
More informationDatabase Technology Introduction. Heiko Paulheim
Database Technology Introduction Outline The Need for Databases Data Models Relational Databases Database Design Storage Manager Query Processing Transaction Manager Introduction to the Relational Model
More informationThe Relational Model. Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC)
The Relational Model Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) Why Study the Relational Model? Most widely used model in Commercial DBMSs: Vendors: IBM, Microsoft,
More informationDC62 Database management system JUNE 2013
Q2 (a) Explain the differences between conceptual & external schema. Ans2 a. Page Number 24 of textbook. Q2 (b) Describe the four components of a database system. A database system is composed of four
More informationRelational data model
Relational data model Iztok Savnik FAMNIT, 18/19 Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. Legacy systems in older models E.G., IBM
More information