Time: Location: Base -------------------------------------------------------------------------- building a database application is a very complex task, including a database design mode, design the program for accessing and updating data, and design the Security Mode for controlling data access. The database has many intended uses
Time: Location: Base -------------------------------------------------------------------------- building a database application is a very complex task, including a database design mode, design the program for accessing and updating data, and design the Security Mode for controlling data access. The database has many intended uses
Time: 2014.04.18
Location: Base
--------------------------------------------------------------------
Building a database application is a very complex task, including designing database patterns, designing programs for accessing and updating data, and designing a secure mode for controlling data access. The intended use of databases affects various options at the physical, logical, and view levels in many ways.
--------------------------------------------------------------------
I. Design Phase 1. preliminary stage (understanding Requirements ):
It fully depicts the data requirements of database users in the future. -- Because real applications are often very complex, database designers should interact with application users to understand application requirements and express them in advanced forms that users can understand, then, the requirement is transformed into a lower-level design. Therefore, designers should have in-depth communication with experts and users in the application field to list requirement specifications.
2. Conceptual Design Phase (converting requirements into concepts and building entities-contact diagrams ):
Select a data model and use the concept of this model to convert a requirement into a data conceptual model. -- This is a conceptual design phase. For example, we usually use an object-link model, which defines the entities represented in the database, the attributes of entities, and the links between entities, and constraints on entities and associations. The result of the conceptual design phase is to build an entity-contact diagram that provides a graphical description of the pattern. At this stage, we focus on describing the data and its relationships, rather than defining the details of physical storage, and ensuring that the data in this mode meets the requirements.
3. Concept Design Stage (description of functional requirements and specifications, including modifying and updating data, searching and retrieving data, and deleting data)
The above steps are implemented by the abstract database, while the database implementation includes the logical design phase and the physical design phase.
4. Logic Design Phase:
The designer maps high-level conceptual patterns to the data models implemented by the database system used. The data model is usually a relational data model. This ing is generally used to map the conceptual mode defined by the entity-contact model to the relational mode.
5. Physical Design Phase
The designer applies the specific database mode of the obtained system to the subsequent physical design phase. This stage specifies the physical characteristics of the database, including the selection of the file organization format and index structure.
--------------------------------------------------------------------
Ii. Design Selection
Entities are used to describe and indicate all identifiable individuals in the database. For example, teachers, students, departments, and courses in a university database are entities. These entities involve various relationships, which will be reflected in the database design process.
Two defects that should be avoided during Database Design
1. Design Redundancy
Poor database design may duplicate information. Information Redundancy can cause problems when a piece of information is updated, the redundant part of the information is not updated in a timely manner, the consequence is that the two copies will become inconsistent when the same meaning is expressed. Ideally, the information should only appear once and should not be redundant.
2. Incomplete design
In short, database design is actually a very challenging issue and requires the combination of science and good taste.
--------------------------------------------------------------------
Entity-contact model (E-R)
The database model is designed to facilitate database design. It is implemented by allowing the enterprise mode that represents the global logical structure of the database.
Several Concepts of E-R Model:
1. entity set
An object is a thing or object that can be different from all other objects in the real world. For example, each individual in a university is an entity, which can be different from others. Each entity also has a set of properties, and some values can uniquely identify an entity, at least in a collection of objects, such as student ID and ID card number.
An entity set is a set of objects of the same type or nature. For example, you can define all the teachers in a university as an entity set and put all the teachers in it. At the same time, the extension of an entity set refers to the actual set of entities in an entity set, which is a bit confusing. Specifically, there must be many entities in an entity set, A set of actually existing entities in the entity set is the extension of the entity set.
An object is represented by a set of attributes, which describe the nature of each member in an object set. Each object has its own value on each attribute.
Therefore, a database includes a set of entities. Each entity set includes any number of entities of the same type. For example, a university database contains two entity sets: teachers and students, these two entity sets have their own entity composition. And have corresponding attributes. Of course, there are more entity sets, such as courses, colleges, and so on.
2. Contact set
Association refers to the association between multiple entities. For example, you can define the relationship between a teacher X and a student Y, which indicates that teacher X is the mentor of student Y.
Contact set: a set of the same type of association. It corresponds to all the implementations of a link, for example, between an entity set instructor and an entity set student, there is a relationship between teachers and students. The ing of these many teacher-student relationships is a connection set. At this time, we also said that entity set teachers and entity set students are involved in this association set. For example, a teacher entity with a teacher ID of 201314 and a student entity with a student ID of 201208 participate in a contact instance between the teacher and the student. The contact instance indicates that the teacher is the tutor of the student.
In addition, connections can also have attributes, such as the relationship between teachers and students in the entity set. We can create an attribute in the relationship between teachers and students, indicating the start date of the teacher-student relationship, for example, for entity set students and course set courses, you can use a score attribute in this contact set to record the scores of students at the end of the course. It is worth noting that instances in the contact set are uniquely identified by participating in the entity and are irrelevant to the description attribute. The same entity set may also be involved in an additional contact set.
In a consortium, most of them are binary, that is, only two entities are involved in the consortium. Sometimes there may be two more. The number of entity sets involved in the contact set is called the degree of the contact set, and the degree of the binary contact set is 2.
3. Attributes
As mentioned above, each attribute has a set of merits, called the attribute field or value set. Such as the definition and value fields of a function. Here, the attribute of an object set is a function that maps an object set to a domain. Because an object set may have multiple attributes, each object is generally represented by a group of (attribute, data value) pairs. For example, the instructor entity can be described in {(ID, 201314), (name, John), (dept_name, information), (salary, 72000)} sets.
3.1 simple and compliant attributes
Simple attributes cannot be further divided, but composite attributes, such as attribute name, can be divided into smaller attributes, first_name, middle_namd, and last_name. In this case, "name" is the property. Of course, this is customized by the designer, rather than static. If you think that "name" is an integral whole, it is a simple property. If a user wants to reference integrity attributes in some scenarios and only needs a part of the attributes in other scenarios, it is a good choice to use composite attributes in design mode. For example, in a university database, an address attribute can be added to an entity set student, which can be subdivided into sub-attributes such as province, city, and county.
3.2 Single-value and multi-value Attributes
Generally, an attribute has only one value for a specific object. For example, a student has only one student ID, and this student ID attribute is a single value. In some cases, for example, a contact number, multiple values can be obtained for a specific object. When expressing a multi-value attribute, we use curly brackets to enclose the attribute name. For example: {phone_number}. In addition, we can set the upper or lower limits for such multi-value features.
3.3 derived attributes
The value of the derived attribute can be derived from other related attributes and entities, such as the number of instructors and attribute students in the entity set, which indicates the number of students corresponding to the instructor guidance, the number of students is the property value obtained by counting the number of all student entities associated with a teacher. Such an attribute is called a derived attribute. For example, the entity set instructor already has the age attribute age. If you want to have the birth date attribute date_of_birth, you can calculate the age from the current date and date_of_birth, in this way, age is a derived attribute, and date_of_birth is called a base attribute or a storage attribute.
In a word, the values of derived attributes do not need to be stored, but are calculated as needed. If the attribute has no value, null is used.