20
CHAPTER 2 Exploring Relational Database Components รรรรรรรรรรรรรรรรรรรร (Advanced Database Systems) Lecturer AJ. Suwan Janin Phone: 089-148-3993 E-mail: [email protected]

CHAPTER 2 Exploring Relational Database Components

  • Upload
    dane

  • View
    79

  • Download
    4

Embed Size (px)

DESCRIPTION

ระบบฐานข้อมูลขั้นสูง (Advanced Database Systems). CHAPTER 2 Exploring Relational Database Components. Lecturer AJ . Suwan Janin. Phone: 089-148-3993 E-mail: [email protected]. Outline. Conceptual Database Design Components Entities Attributes Relationships One-to-One Relationships - PowerPoint PPT Presentation

Citation preview

Page 1: CHAPTER 2 Exploring Relational Database Components

CHAPTER 2Exploring Relational DatabaseComponents

ระบบฐานขอ้มูลขัน้สงู(Advanced Database Systems)

LecturerAJ. Suwan Janin

Phone: 089-148-3993E-mail: [email protected]

Page 2: CHAPTER 2 Exploring Relational Database Components

Outline Conceptual Database Design Components

Entities Attributes Relationships▪ One-to-One Relationships▪ One-to-Many Relationships▪ Many-to-Many Relationships

Business Rules Logical/Physical Database Design

Components Constraints Views

Page 3: CHAPTER 2 Exploring Relational Database Components

Introduction on Chapter 2• explore the conceptual, logical and physical components to relational model.• Conceptual database design is a modeling the data in a technology-independent manner.• Person performs conceptual database design , called a data modeler.• Logical database design is the process of translating, or mapping, the conceptual design into a logical design that fits the chosen database model (relational, object-oriented, object-relational, and so on). • A specialist who performs logical database design is called a database designer or database administrator (DBA)

Page 4: CHAPTER 2 Exploring Relational Database Components

Introduction on Chapter 2 (cont.)• Final design step is physical database design, involves mapping the logical design to one or more physical . • DBMS manage database and computer system on the database running. • DBA performs physicaldatabase design.

In the sections that follow, we explore the components of a conceptual database design, then the components of a logical and physical design.

Page 5: CHAPTER 2 Exploring Relational Database Components

Conceptual Database Design Components

Conceptual design for Northwind DBM.Entity, Attribute, Relationship, Business Rule, and Intersection Data are the basic components , make up a conceptual database design.

Page 6: CHAPTER 2 Exploring Relational Database Components

Entities• An entity is a person, place, thing, event, or concept about data is collected or the real world things in which have sufficient interest to capture and store data about them in a database. • An entity is represented as a rectangle on the diagram. Just about anything that can be named with a noun can be an entity.• External entity is an entity with which our database exchanges data such as credit accounts for customers purchase, credit bureaus ==> ID ==> credit report, or all data about customer.• Credit bureau not appear in conceptual database design appear in data flow diagrams as a source or destination of data in Chapter 7

Page 7: CHAPTER 2 Exploring Relational Database Components

Attributes• Attribute is a unit fact that characterizes or describes an entity in someway as names inside the rectangle represents the entity to they belong. • The attribute appears at the top of the rectangle (above the horizontal line) is the unique identifier for the entity suchas the name suggests, provides a unique value for each instance of the entity. • For example, the Customer_ID attribute is the unique identifier for the Customer entity, customer must have a unique value.• Attribute must describe or characterize of entity in some way (for example, size, shape, color, quantity, location).

Page 8: CHAPTER 2 Exploring Relational Database Components

Relationships• Relationships are the associations among the entities. Databases are storing related data, the relationships become the glue that holds the database together. • Relationships are shown on the conceptual design diagramas lines connecting one or more entities. • The maximum cardinality may be one (where the line has no special symbol on its end) or many (where the line has a crow’s foot on the end). • The minimum cardinality may be zero, denoted with a circledrawn on the line, or one, denoted with a short vertical line or tick mark drawn across the relationship line.• Many data modelers use two vertical lines to mean “one and only one.”

Page 9: CHAPTER 2 Exploring Relational Database Components

Relationships (cont.)For the relationship between Customer and Order, for example, we must ask two questions: “Each customer can have how many orders?” followed by “Each order can have how many customers?” Relationships may thus be classified into three types: one-to-one, one-to-many, and many-to-many, as discussed in the following sections. Some people will say many-to-one is also a relationship type, but in reality, it is only a one-to-many relationship looked at with a reverse perspective. Relationship types are best learned by example. Getting the relationships right is essential to a successful design.

Page 10: CHAPTER 2 Exploring Relational Database Components

One-to-One Relationships

• One-to-one If we were to track which employees had other employeesas spouses, we would expect each to be married to either zero or one otheremployee.

Page 11: CHAPTER 2 Exploring Relational Database Components

One-to-Many Relationships• One-to-many It is very common to track the employment “food chain” of who reports to whom. In most organizations, people have only one supervisor or manager. Therefore, we normally expect to see each employee reporting to zero or one other employee, and employees who are managersor supervisors to have one or more direct reports.

Page 12: CHAPTER 2 Exploring Relational Database Components

Many-to-Many Relationships

• Many-to-many In manufacturing, a common relationship has to do with parts that make up a finished product. If you think about the CD-ROM drive in a personal computer, for example, you can easily imagine that it is made of multiple parts, and yet, it is only one part of your personal computer. So,any part can be made of many other parts, and at the same time, any partcan be a component of many other parts.

Page 13: CHAPTER 2 Exploring Relational Database Components

Business RulesA business rule is a policy, procedure, or standard that an organization has adopted. Business rules are very important in database design because they dictate controls that must be placed upon the data. In Figure 2-1

Page 14: CHAPTER 2 Exploring Relational Database Components

Logical/Physical Database Design Components

TablesThe primary unit of storage in the relational model is the table, which is a two dimensional structure composed of rows and columns. Each row represents one occurrence of the entity that the table represents, and each column represents one attribute for that entity.

Microsoft Office Access Application

Page 15: CHAPTER 2 Exploring Relational Database Components

Columns and Data Types

• Restricting the data in the column to characters that make sense for the data type (for example, all numeric digits or only valid calendar dates).• Providing a set of behaviors useful to the database user. For example, if you subtract a number from another number, you get a number as a result; but if you subtract a date from another date, you get a number representing the elapsed days between the two dates as a result.• Assisting the RDBMS in efficiently storing the column data. For example, numbers can often be stored in an internal numeric format that saves space, compared with merely storing the numeric digits as a string of characters.

Page 16: CHAPTER 2 Exploring Relational Database Components

Constraints

A primary key is a column or a set of columns that uniquely identifies each row in a table. A unique identifier in the conceptual design is thus implemented as a primary key in the logical design. The small icon that looks like a door key to the left of the Order ID field name in Figure 2-6 indicates that this column has been defined as the primary key of the Orders table

Primary Key Constraints

Referential ConstraintsEach relationship between entities in the conceptual design becomes a referential constraint in the logical design. A referential constraint (sometimes called a referential integrity constraint) is a constraint that enforces a relationship among tables in a relational database.

Page 17: CHAPTER 2 Exploring Relational Database Components

Why Focus on Relational?

Page 18: CHAPTER 2 Exploring Relational Database Components

Relationships

Page 19: CHAPTER 2 Exploring Relational Database Components

View (Query)Views serve a number of useful functions:• Hiding columns that the user does not need to see (or should not be allowed to see)• Hiding rows from tables that a user does not need to see (or should not be allowed to see)• Hiding complex database operations such as table joins• Improving query performance (in some RDBMSs, such asMicrosoft SQL Server)

Page 20: CHAPTER 2 Exploring Relational Database Components

Q&A???????

THANK YOU FOR YOUR KIND ATTENTION !!!

LecturerAJ. Suwan Janin