SlideShare ist ein Scribd-Unternehmen logo
1 von 64
Translation of ER-diagram into Relational Schema Prof. Sin-Min Lee Department of Computer Science CS 157A Lecture 7
Learning Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],9.2 ,[object Object],[object Object]
 
9.
 
Process of Database Design  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],9.
9.
Relational Database Model ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],9.
Relational Database Model ,[object Object],[object Object],9.
Transforming E-R Diagrams into Relations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],9.
Transforming E-R Diagrams into Relations ,[object Object],[object Object],[object Object],9.
9.
 
Transforming E-R Diagrams into Relations ,[object Object],[object Object],[object Object],[object Object],9.
9.
Transforming E-R Diagrams into Relations ,[object Object],[object Object],[object Object],[object Object],[object Object],9.
Transforming E-R Diagrams into Relations ,[object Object],[object Object],[object Object],9.
9.
Transforming E-R Diagrams into Relations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],9.
9.
9.
Primary Key Constraints ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Primary key can not have null value
Foreign Keys, Referential Integrity ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Enforcing Referential Integrity ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Logical DB Design: ER to Relational ,[object Object],CREATE TABLE  Employees  (ssn  CHAR (11), name  CHAR (20), lot  INTEGER , PRIMARY KEY  (ssn) )‏ Employees ssn name lot
Relationship Sets to Tables ,[object Object],[object Object],[object Object],[object Object],CREATE TABLE  Works_In( ssn  CHAR (1), did  INTEGER , since  DATE , PRIMARY KEY  (ssn, did), FOREIGN KEY  (ssn)  REFERENCES  Employees, FOREIGN KEY  (did)  REFERENCES  Departments )‏
Review: Key Constraints ,[object Object],Translation to  relational model? Many-to-Many 1-to-1 1-to Many Many-to-1 budget did Departments dname since lot name ssn Manages Employees
Translating ER Diagrams with Key Constraints ,[object Object],[object Object],[object Object],[object Object],CREATE TABLE  Manages( ssn  CHAR(11) , did  INTEGER , since  DATE , PRIMARY KEY  (did) , FOREIGN KEY  (ssn)  REFERENCES  Employees, FOREIGN KEY  (did)  REFERENCES  Departments )‏ CREATE TABLE  Dept_Mgr( did  INTEGER, dname  CHAR(20), budget  REAL, ssn  CHAR(11) , since  DATE , PRIMARY KEY  (did), FOREIGN KEY  (ssn)  REFERENCES  Employees )‏
Review: Participation Constraints ,[object Object],[object Object],[object Object],lot name dname budget did since name dname budget did since Manages since Departments Employees ssn Works_In
Participation Constraints in SQL ,[object Object],CREATE TABLE  Dept_Mgr( did  INTEGER, dname  CHAR(20), budget  REAL, ssn  CHAR(11)  NOT NULL , since  DATE, PRIMARY KEY  (did), FOREIGN KEY  (ssn) REFERENCES Employees, ON DELETE NO ACTION )‏
Review: Weak Entities ,[object Object],[object Object],[object Object],lot name age pname Dependents Employees ssn Policy cost
 
Translating Weak Entity Sets ,[object Object],[object Object],CREATE TABLE  Dep_Policy ( pname  CHAR(20) , age  INTEGER , cost  REAL , ssn  CHAR(11) NOT NULL , PRIMARY KEY  (pname, ssn), FOREIGN KEY  (ssn)  REFERENCES  Employees, ON DELETE CASCADE )‏
Review: Binary vs. Ternary Relationships ,[object Object],[object Object],[object Object],age pname Dependents Covers age pname Dependents Purchaser Bad design Better design name Employees ssn lot Policies policyid cost Beneficiary policyid cost Policies name Employees ssn lot
Binary vs. Ternary Relationships (Contd.)‏ ,[object Object],[object Object],[object Object],CREATE TABLE  Policies ( policyid  INTEGER , cost  REAL , ssn  CHAR(11)  NOT NULL , PRIMARY KEY  (policyid). FOREIGN KEY  (ssn)  REFERENCES  Employees, ON DELETE CASCADE )‏ CREATE TABLE  Dependents   ( pname  CHAR(20) , age  INTEGER , policyid  INTEGER , PRIMARY KEY  (pname, policyid). FOREIGN KEY  (policyid)  REFERENCES  Policies, ON DELETE CASCADE )‏
 
 
An Example CREATE TABLE Student ( ID   NUMBER, Fname  VARCHAR2(20), Lname  VARCHAR2(20), );
Constraints in Create Table ,[object Object],[object Object],[object Object],[object Object],[object Object]
Not Null Constraint CREATE TABLE Student ( ID   NUMBER, Fname  VARCHAR2(20)  NOT NULL , Lname  VARCHAR2(20)  NOT NULL , );
Primary Key Constraint Primary Key implies: * NOT NULL * UNIQUE.  There can only be one primary key. CREATE TABLE Student ( ID   NUMBER  PRIMARY KEY , Fname  VARCHAR2(20) NOT NULL, Lname  VARCHAR2(20) NOT NULL, );
Primary Key Constraint  (Syntax 2)‏ CREATE TABLE Students ( ID   NUMBER, Fname  VARCHAR2(20) NOT NULL, Lname  VARCHAR2(20) NOT NULL, PRIMARY KEY(ID)‏ ); Needed when the primary key is made up of two or more fields
Another Table CREATE TABLE Studies( Course   NUMBER, Student  NUMBER ); What additional constraint do we want on Student? What should be the primary key?
Foreign Key Constraint NOTE: ID must be unique (or primary key) in Student CREATE TABLE Studies( Course   NUMBER, Student  NUMBER, FOREIGN KEY (Student) REFERENCES   Students(ID)‏ );
Translating ER-Diagrams to Table Definitions
Relations vs. Tables ,[object Object],[object Object],[object Object],[object Object]
Translating Entities ,[object Object],[object Object],[object Object],[object Object],Actor id name address birthday
Translating Entities ,[object Object],[object Object],[object Object],[object Object],Actor id name address birthday Relation: Actor ( id , name, birthday, address)‏
Translating Relationships  (without constraints)‏ ,[object Object],[object Object],[object Object],[object Object],[object Object],Actor id name address birthday Acted In Film title type year salary
Translating relationships  (without constraints)‏ ,[object Object],[object Object],Actor id name address birthday Acted In Film title type year salary
Translating Recursive Relationships  (without constraints)‏ Employee id name address Manages manager worker Relation: Actor ( worker-id ,  manager-id )‏ What would be the table definition?
Translating relationships (key constraints): Option 1 ,[object Object],[object Object],Director id name Directed Film title salary year
Translating relationships (key constraints): Option 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],Director id name Directed Film title salary year What primary and foreign keys are missing?
Translating relationships (key constraints): Option 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],Director id name Directed Film title salary year
Translating relationships (key constraints): Option 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],Director id name Directed Film title salary year What 3 lines are missing?
Translating relationships (key constraints)‏ ,[object Object],A R B C
Translating relationships (participation constraints)‏ ,[object Object],[object Object],[object Object],Director id name Directed Film title salary year
Translating relationships (participation constraints)‏ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Director id name Directed Film title salary year Where should we add NOT NULL?
Translating relationships (participation constraints)‏ ,[object Object],Actor id name Acted In Film title salary year
Translating Weak Entity Sets ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Award Organization Gives year name name phone number money
Translating ISA: Option 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Movie Person ISA id name address picture Director Actor
Translating ISA: Option 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Movie Person ISA id name address picture Director Actor
Which Option To Choose? ,[object Object],[object Object],[object Object]
Translating Aggregation ,[object Object],[object Object],[object Object],Actor picture Film year type title Acted In salary Award Organization Gives year name name phone number Won

Weitere ähnliche Inhalte

Was ist angesagt?

3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
koolkampus
 
Chapter 7 relation database language
Chapter 7 relation database languageChapter 7 relation database language
Chapter 7 relation database language
Jafar Nesargi
 
Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2
eidah20
 

Was ist angesagt? (20)

Chapter3
Chapter3Chapter3
Chapter3
 
Chapter 2 Relational Data Model-part 2
Chapter 2 Relational Data Model-part 2Chapter 2 Relational Data Model-part 2
Chapter 2 Relational Data Model-part 2
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
 
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database ConstraintsThe Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints
 
Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1
 
Chapter 7 relation database language
Chapter 7 relation database languageChapter 7 relation database language
Chapter 7 relation database language
 
ER to relational Mapping: Data base design using ER to relational language. C...
ER to relational Mapping: Data base design using ER to relational language. C...ER to relational Mapping: Data base design using ER to relational language. C...
ER to relational Mapping: Data base design using ER to relational language. C...
 
Chapter7
Chapter7Chapter7
Chapter7
 
Lesson03 the relational model
Lesson03 the relational modelLesson03 the relational model
Lesson03 the relational model
 
Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)
 
L8 design1
L8 design1L8 design1
L8 design1
 
Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
 
Chapter 2 Relational Data Model-part 3
Chapter 2 Relational Data Model-part 3Chapter 2 Relational Data Model-part 3
Chapter 2 Relational Data Model-part 3
 
ch6
ch6ch6
ch6
 
Kul 2
Kul 2Kul 2
Kul 2
 
Relational model
Relational modelRelational model
Relational model
 
Dbms relational data model and sql queries
Dbms relational data model and sql queries Dbms relational data model and sql queries
Dbms relational data model and sql queries
 

Andere mochten auch

ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ARADHYAYANA
 
ER model to Relational model mapping
ER model to Relational model mappingER model to Relational model mapping
ER model to Relational model mapping
Shubham Saini
 
Entity Relationship Diagram presentation
Entity Relationship Diagram presentationEntity Relationship Diagram presentation
Entity Relationship Diagram presentation
Sopov Chan
 
How to Draw an Effective ER diagram
How to Draw an Effective ER diagramHow to Draw an Effective ER diagram
How to Draw an Effective ER diagram
Tech_MX
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
tameemyousaf
 

Andere mochten auch (20)

ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
 
ER model to Relational model mapping
ER model to Relational model mappingER model to Relational model mapping
ER model to Relational model mapping
 
Assignment 1 of Database (MySQL & Sqlite3)
Assignment 1 of Database (MySQL & Sqlite3) Assignment 1 of Database (MySQL & Sqlite3)
Assignment 1 of Database (MySQL & Sqlite3)
 
Crj 3 1-b
Crj 3 1-bCrj 3 1-b
Crj 3 1-b
 
Entity Relationship Diagram presentation
Entity Relationship Diagram presentationEntity Relationship Diagram presentation
Entity Relationship Diagram presentation
 
Erd practice exercises
Erd practice exercisesErd practice exercises
Erd practice exercises
 
Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)
 
How to Draw an Effective ER diagram
How to Draw an Effective ER diagramHow to Draw an Effective ER diagram
How to Draw an Effective ER diagram
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
 
Er diagram
Er diagramEr diagram
Er diagram
 
Try PostgreSQL on linux
Try PostgreSQL on linuxTry PostgreSQL on linux
Try PostgreSQL on linux
 
Vanson Bourne Data Summary: Shadow IT - BDMs
Vanson Bourne Data Summary: Shadow IT - BDMsVanson Bourne Data Summary: Shadow IT - BDMs
Vanson Bourne Data Summary: Shadow IT - BDMs
 
00137
0013700137
00137
 
Prison management system
Prison management system Prison management system
Prison management system
 
Example Database normal form
Example Database normal formExample Database normal form
Example Database normal form
 
15123 entity relational diagram
15123 entity relational diagram15123 entity relational diagram
15123 entity relational diagram
 
Special lecture er diagram
Special lecture er diagramSpecial lecture er diagram
Special lecture er diagram
 
Information system development
Information system developmentInformation system development
Information system development
 
Assignment 2 of Database (Database Security)
Assignment 2 of Database (Database Security)Assignment 2 of Database (Database Security)
Assignment 2 of Database (Database Security)
 
Lab ex 1
Lab ex 1Lab ex 1
Lab ex 1
 

Ähnlich wie Eer >r.model

4_RelationalDataModelAndRelationalMapping.pdf
4_RelationalDataModelAndRelationalMapping.pdf4_RelationalDataModelAndRelationalMapping.pdf
4_RelationalDataModelAndRelationalMapping.pdf
LPhct2
 
Ch 6 Logical D B Design
Ch 6  Logical D B  DesignCh 6  Logical D B  Design
Ch 6 Logical D B Design
guest8fdbdd
 

Ähnlich wie Eer >r.model (20)

Unit03 dbms
Unit03 dbmsUnit03 dbms
Unit03 dbms
 
Unit03 dbms
Unit03 dbmsUnit03 dbms
Unit03 dbms
 
Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013
 
DBMS-Unit-2.pptx
DBMS-Unit-2.pptxDBMS-Unit-2.pptx
DBMS-Unit-2.pptx
 
4_RelationalDataModelAndRelationalMapping.pdf
4_RelationalDataModelAndRelationalMapping.pdf4_RelationalDataModelAndRelationalMapping.pdf
4_RelationalDataModelAndRelationalMapping.pdf
 
DEE 431 Database keys and Normalisation Slide 2
DEE 431 Database keys and Normalisation Slide 2DEE 431 Database keys and Normalisation Slide 2
DEE 431 Database keys and Normalisation Slide 2
 
RDBMS
RDBMSRDBMS
RDBMS
 
NMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.pptNMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.ppt
 
Ch3_Rel_Model-95.ppt
Ch3_Rel_Model-95.pptCh3_Rel_Model-95.ppt
Ch3_Rel_Model-95.ppt
 
uniT 4 (1).pptx
uniT 4 (1).pptxuniT 4 (1).pptx
uniT 4 (1).pptx
 
Ch 6 Logical D B Design
Ch 6  Logical D B  DesignCh 6  Logical D B  Design
Ch 6 Logical D B Design
 
Int_SQL.pdf
Int_SQL.pdfInt_SQL.pdf
Int_SQL.pdf
 
2. Relational_Data_Model_Keys_10b.pptx
2. Relational_Data_Model_Keys_10b.pptx2. Relational_Data_Model_Keys_10b.pptx
2. Relational_Data_Model_Keys_10b.pptx
 
Unit04 dbms
Unit04 dbmsUnit04 dbms
Unit04 dbms
 
Fg d
Fg dFg d
Fg d
 
Preparing for BIT – IT2301 Database Management Systems 2001d
Preparing for BIT – IT2301 Database Management Systems 2001dPreparing for BIT – IT2301 Database Management Systems 2001d
Preparing for BIT – IT2301 Database Management Systems 2001d
 
Understanding about relational database m-square systems inc
Understanding about relational database m-square systems incUnderstanding about relational database m-square systems inc
Understanding about relational database m-square systems inc
 
Unit 2 DBMS
Unit 2 DBMSUnit 2 DBMS
Unit 2 DBMS
 
U2_ER_modeling.pptx
U2_ER_modeling.pptxU2_ER_modeling.pptx
U2_ER_modeling.pptx
 
ER to Relational Mapping
ER to Relational MappingER to Relational Mapping
ER to Relational Mapping
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Eer >r.model

  • 1. Translation of ER-diagram into Relational Schema Prof. Sin-Min Lee Department of Computer Science CS 157A Lecture 7
  • 2.
  • 3.  
  • 4. 9.
  • 5.  
  • 6.
  • 7. 9.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12. 9.
  • 13.  
  • 14.
  • 15. 9.
  • 16.
  • 17.
  • 18. 9.
  • 19.
  • 20. 9.
  • 21. 9.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.  
  • 33.
  • 34.
  • 35.
  • 36.  
  • 37.  
  • 38. An Example CREATE TABLE Student ( ID NUMBER, Fname VARCHAR2(20), Lname VARCHAR2(20), );
  • 39.
  • 40. Not Null Constraint CREATE TABLE Student ( ID NUMBER, Fname VARCHAR2(20) NOT NULL , Lname VARCHAR2(20) NOT NULL , );
  • 41. Primary Key Constraint Primary Key implies: * NOT NULL * UNIQUE. There can only be one primary key. CREATE TABLE Student ( ID NUMBER PRIMARY KEY , Fname VARCHAR2(20) NOT NULL, Lname VARCHAR2(20) NOT NULL, );
  • 42. Primary Key Constraint (Syntax 2)‏ CREATE TABLE Students ( ID NUMBER, Fname VARCHAR2(20) NOT NULL, Lname VARCHAR2(20) NOT NULL, PRIMARY KEY(ID)‏ ); Needed when the primary key is made up of two or more fields
  • 43. Another Table CREATE TABLE Studies( Course NUMBER, Student NUMBER ); What additional constraint do we want on Student? What should be the primary key?
  • 44. Foreign Key Constraint NOTE: ID must be unique (or primary key) in Student CREATE TABLE Studies( Course NUMBER, Student NUMBER, FOREIGN KEY (Student) REFERENCES Students(ID)‏ );
  • 45. Translating ER-Diagrams to Table Definitions
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51. Translating Recursive Relationships (without constraints)‏ Employee id name address Manages manager worker Relation: Actor ( worker-id , manager-id )‏ What would be the table definition?
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.

Hinweis der Redaktion

  1. 6
  2. 7
  3. 13
  4. 3 The slides for this text are organized into several modules. Each lecture contains about enough material for a 1.25 hour class period. (The time estimate is very approximate--it will vary with the instructor, and lectures also differ in length; so use this as a rough guideline.) This covers Lectures 1 and 2 (of 6) in Module (5). Module (1): Introduction (DBMS, Relational Model)‏ Module (2): Storage and File Organizations (Disks, Buffering, Indexes)‏ Module (3): Database Concepts (Relational Queries, DDL/ICs, Views and Security)‏ Module (4): Relational Implementation (Query Evaluation, Optimization)‏ Module (5): Database Design (ER Model, Normalization, Physical Design, Tuning)‏ Module (6): Transaction Processing (Concurrency Control, Recovery)‏ Module (7): Advanced Topics
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 7
  13. 8
  14. 15