36

Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

  • Upload
    others

  • View
    18

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom
Page 2: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Database Foundations 5-1 Mapping Entities and Attributes

Page 3: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Road Map

Mapping Entities and Attributes Mapping

Primary and Foreign Keys

You are here

3 DFo 5-1 Mapping Entities and Attributes

Page 4: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Objectives This lesson covers the following objectives: • Describe why you need to create a relational model • Explain the naming conventions used in a relational

database

4 DFo 5-1 Mapping Entities and Attributes

Page 5: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Objectives This lesson covers the following objectives: • Use Oracle SQL Developer Data Modeler to apply

naming standards by creating: – Glossary – Name abbreviations – Design rules – Custom rules – Transformations

• Map simple entities to tables • Map attributes to column names

5 DFo 5-1 Mapping Entities and Attributes

Page 6: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Need for Creating a Relational Model A relational model: • Is the blue print for the actual database implementation • Can be used as the basis for implementing any type of

DBMS. The ideal model can be adapted to an RDBMS model.

6 DFo 5-1 Mapping Entities and Attributes

Page 7: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Transformation Process: Logical to Relational Model

Transformation

Logical Model

Relational Model

7 DFo 5-1 Mapping Entities and Attributes

Page 8: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Tables: A Recap Table: EMPLOYEES

ID Name Address Birth_date Department_ID

110 Jones 12 Oxford Street 03-03-66 10

301 Smith 53 Hayes Drive 08-12-53 20

134 Gonzales 5609 Maple Court 10-02-87 40

Rows

Primary key column

Columns

Foreign key column to the DEPARTMENTS table

Table in the relational model

8 DFo 5-1 Mapping Entities and Attributes

Page 9: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Terminology Mapping: A Recap

ANALYSIS DESIGN

Logical model Relational model

Entity Table

Attribute Column

Primary UID Primary key

Secondary UID Unique constraint

Relationship Foreign key

Business constraints Check constraints

9 DFo 5-1 Mapping Entities and Attributes

Page 10: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Naming Conventions Decide on conventions for: • Table names • Column names and special characters (%, *, #, -, space,

…) • Table short names (abbreviations)

10 DFo 5-1 Mapping Entities and Attributes

Page 11: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Naming Conventions Decide on conventions for: • Primary and unique key constraint names • Foreign key constraint names • Foreign key column names • Check constraints

11 DFo 5-1 Mapping Entities and Attributes

Page 12: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Naming Restrictions with Oracle Database • Table and column names:

– Must start with a letter – May contain up to 30 alphanumeric characters – Must not contain spaces or some special characters – Must avoid reserved words

• Table names must be unique within a schema. • Column names must be unique within a table.

12 DFo 5-1 Mapping Entities and Attributes

Page 13: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Applying Naming Standards Using Oracle SQL Developer Data Modeler

Logical Model

Relational Model

Glossary

Naming Templates

Naming Restrictions

Name Translation

Name Formatter

Design Rule Validation

13 DFo 5-1 Mapping Entities and Attributes

Page 14: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Glossary Creating a Glossary from a Logical Model

14 DFo 5-1 Mapping Entities and Attributes

Page 15: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Glossary Editor

15 DFo 5-1 Mapping Entities and Attributes

Page 16: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Glossary Editor

16 DFo 5-1 Mapping Entities and Attributes

Page 17: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Name Abbreviations

Example of a .csv file content

17 DFo 5-1 Mapping Entities and Attributes

Page 18: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Executing Design Rules

18 DFo 5-1 Mapping Entities and Attributes

a

b

Page 19: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Creating Rule Sets for Design Rules

19 DFo 5-1 Mapping Entities and Attributes

a

b

c

Page 20: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Custom Design Rules and Transformation

20 DFo 5-1 Mapping Entities and Attributes

Page 21: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Custom Design Rules and Transformation

21 DFo 5-1 Mapping Entities and Attributes

Page 22: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Case Scenario: Design Rules

Let me see if the ERD for the Simplified Library

Management System is complying with the

database design rules.

If the ERD is not complying with the

design rules, can I fix it?

22 DFo 5-1 Mapping Entities and Attributes

Page 23: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Case Scenario: Applying Design Rules

The warning is fixed, and now the design is

OK.

23 DFo 5-1 Mapping Entities and Attributes

a

b

c

Page 24: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Mapping Simple Entities to Tables •Entities

Tables

24 DFo 5-1 Mapping Entities and Attributes

Page 25: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Naming Entities

25 DFo 5-1 Mapping Entities and Attributes

a

b

c

Page 26: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Engineering Entities

26 DFo 5-1 Mapping Entities and Attributes

Page 27: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Mapping Attributes to Columns •Entities

Tables

27 DFo 5-1 Mapping Entities and Attributes

Page 28: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Mapping Attributes to Columns: Column Names

28 DFo 5-1 Mapping Entities and Attributes

Page 29: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Engineering Attributes

29 DFo 5-1 Mapping Entities and Attributes

Page 30: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Reviewing the Glossary

30 DFo 5-1 Mapping Entities and Attributes

Page 31: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Adding the Glossary as the Naming Standard

31 DFo 5-1 Mapping Entities and Attributes

a

b

c

Page 32: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Mapping Attributes to Columns with the Glossary

•Entities

Tables After Glossary Is Applied

32 DFo 5-1 Mapping Entities and Attributes

Page 33: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

b

c a

Applying Name Abbreviations

33 DFo 5-1 Mapping Entities and Attributes

Page 34: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Summary In this lesson, you should have learned how to: • Describe why you need to create a relational model • Explain the naming conventions used in a relational

database

34 DFo 5-1 Mapping Entities and Attributes

Page 35: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

Summary In this lesson, you should have learned how to: • Use Oracle SQL Developer Data Modeler to apply

naming standards by creating: – Glossary – Name abbreviations – Design rules – Custom rules – Transformations

• Map simple entities to tables • Map attributes to column names

35 DFo 5-1 Mapping Entities and Attributes

Page 36: Database Foundations · 2016. 8. 19. · • Use Oracle SQL Developer Data Modeler to apply naming standards by creating: –Glossary –Name abbreviations –Design rules –Custom