位置:首页 > 其它资料

讲关系数据库的结构的计算机英语

2020-02-04发布者:郝悦皓大小:103.06 KB 下载:0

计算机英语 Structure of the Relational database The relational model is the basis for any relational database management system (RDBMS).A relational model has three core components: a collection of objects or relations, operators that act on the objects or relations, and data integrity methods. In other words, it has a place to store the data, a way to create and retrieve the data, and a way to make sure that the data is logically consistent. A relational database uses relations, or two-dimensional tables, to store the information needed to support a business. Let's go over the basic components of a traditional relational database system and look at how a relational database is designed. Once you have a solid understanding of what rows, columns, tables, and relationships are, you'll be well on your way to leveraging the power of a relational database. Tables, Row, and Columns A table in a relational database, alternatively known as a relation, is a two-dimensional structure used to hold related information. A database consists of one or more related tables. Note: Don't confuse a relation with relationships. A relation is essentially a table, and a relationship is a way to correlate, join, or associate two tables. A row in a table is a collection or instance of one thing, such as one employee or one line item on an invoice. A column contains all the information of a single type, and the piece of data at the intersection of a row and a column, a field, is the smallest piece of information that can be retrieved with the database's query language. For example, a table with information about employees might have a column called LAST_NAME that contains all of the employees' last names. Data is retrieved from a table by filtering on both the row and the column. Primary Keys, Datatypes, and Foreign Keys The examples throughout this article will focus on the hypothetical work of Scott Smith, database developer and entrepreneur. He just started a new widget company and wants to implement a few of the basic business functions using the relational database to manage his Human Resources (HR) department. Relation: A two-dimensional structure used to hold related information, also known as a table. Note: Most of Scott's employees were hired away from one of his previous employers, some of whom have over 20 years of experience in the field. As a hiring incentive, Scott has agreed to keep the new employees' original hire date in the new database. Row:A group of one or more data elements in a database table that describes a person, place, or thing. Column:The component of a database table that contains all of the data of the same name and type across all rows. You'll learn about database design in the following sections, but let's assume for the moment that the majority of the database design is completed and some tables need to be implemented. Scott creates the EMP table to hold the basic employee information, and it looks something like this: Notice that some fields in the Commission (COMM) and Manager (MGR) columns do not contain a value; they are blank. A relational database can enforce the rule that fields in a column may or may not be empty. In this case, it makes sense for an employee who is not in the Sales department to have a blank Commission field. It also makes sense for the president of the company to have a blank Manager field, since that employee doesn't report to anyone. Field:The smallest piece of information that can be retrieved by the database query language. A field is found at the intersection of a row and a column in a database table. On the other hand, none of the fields in the Employee Number (EMPNO) column are blank. The company always wants to assign an employee number to an employee, and that number must be different for each employee. One of the features of a relational database is that it can ensure that a value is entered into this column and that it is unique. The EMPNO column, in this case, is the primary key of the table. Primary Key:A column (or columns) in a table that makes the row in the table distinguishable from every other row in the same table. Notice the different datatypes that are stored in the EMP table: numeric values, character or alphabetic values, and date values. As you might suspect, the DEPTNO column contains the department number for the employee. But how do you know what department name is associated with what number? Scott created the DEPT table to hold the descriptions for the department codes in the EMP table. The DEPTNO column in the EMP table contains the same values as the DEPTNO column in the DEPT table. In this case, the DEPTNO column in the EMP table is considered a foreign key to the same column in the DEPT table. A foreign key enforces the concept of referential integrity in a relational database. The concept of referential integrity not only prevents an invalid department number from being inserted into the EMP table, but it also prevents a row in the DEPT table from being deleted if there are employees still assigned to that department. Foreign Key:A column (or columns) in a table that draws its values from a primary or unique key column in another table. A foreign key assists in ensuring the data integrity of a table. Referential IntegrityA method employed by a relational database system that enforces one-tomany relationships between tables. Data Modeling Before Scott created the actual tables in the database, he went through a design process known as data modeling. In this process, the developer conceptualizes and documents all the tables for the database. One of the common methods for modeling a database is called ERA, which stands for entities, relationships, and attributes. The database designer uses an application that can maintain entities, their attributes, and their relationships. In general, an entity corresponds to a table in the database, and the attributes of the entity correspond to columns of the table. Data Modeling:A process of defining the entities, attributes, and relationships between the entities in preparation for creating the physical database. The data-modeling process involves defining the entities, defining the relationships between those entities, and then defining the attributes for each of the entities. Once a cycle is complete, it is repeated as many times as necessary to ensure that the designer is capturing what is important enough to go into the database. Let's take a closer look at each step in the data-modeling process. Defining the Entities First, the designer identifies all of the entities within the scope of the database application.The entities are the persons, places, or things that are important to the organization and need to be tracked in the database. Entities will most likely translate neatly to database tables. For example, for the first version of Scott's widget company database, he identifies four entities: employees, departments, salary grades, and bonuses. These will become the EMP, DEPT, SALGRADE, and BONUS tables. Defining the Relationships Between Entities Once the entities are defined, the designer can proceed with defining how each of the entities is related. Often, the designer will pair each entity with every other entity and ask, "Is there a relationship between these two entities?" Some relationships are obvious; some are not. In the widget company database, there is most likely a relationship between EMP and DEPT, but depending on the business rules, it is unlikely that the DEPT and SALGRADE entities are related. If the business rules were to restrict certain salary grades to certain departments, there would most likely be a new entity that defines the relationship between salary grades and departments. This entity would be known as an associative or intersection table and would contain the valid combinations of salary grades and departments. Associative Table:A database table that stores the valid combinations of rows from two other tables and usually enforces a business rule. An associative table resolves a many-to-many relationship. In general, there are three types of relationships in a relational database: One-to-many The most common type of relationship is one-to-many. This means that for each occurrence in a given entity, the parent entity, there may be one or more occurrences in a second entity, the child entity, to which it is related. For example, in the widget company database, the DEPT entity is a parent entity, and for each department, there could be one or more employees associated with that department. The relationship between DEPT and EMP is one-to-many. One-to-one In a one-to-one relationship, a row in a table is related to only one or none of the rows in a second table. This relationship type is often used for subtyping. For example, an EMPLOYEE table may hold the information common to all employees, while the FULLTIME, PARTTIME, and CONTRACTOR tables hold information unique to full-time employees, part-time employees, and contractors, respectively. These entities would be considered subtypes of an EMPLOYEE and maintain a one-to-one relationship with the EMPLOYEE table. These relationships are not as common as one-to-many relationships, because if one entity has an occurrence for a corresponding row in another entity, in most cases, the attributes from both entities should be in a single entity. Many-to-many In a many-to-many relationship, one row of a table may be related to many rows of another table, and vice versa. Usually, when this relationship is implemented in the database, a third entity is defined as an intersection table to contain the associations between the two entities in the relationship. For example, in a database used for school class enrollment, the STUDENT table has a many-to-many relationship with the CLASS table—one student may take one or more classes, and a given class may have one or more students. The intersection table STUDENT_CLASS would contain the combinations of STUDENT and CLASS to track which students are in which classes. Assigning Attributes to Entities Once the designer has defined the entity relationships, the next step is to assign the attributes to each entity. This is physically implemented using columns, as shown here for the SALGRADE table as derived from the salary grade entity. After the entities, relationships, and attributes have been defined, the designer may iterate the data modeling many more times. When reviewing relationships, new entities may be discovered. For example, when discussing the widget inventory table and its relationship to a customer order, the need for a shipping restrictions table may arise. Once the design process is complete, the physical database tables may be created. Logical database design sessions should not involve physical implementation issues, but once the design has gone through an iteration or two, it's the DBA's job to bring the designers "down to earth." As a result, the design may need to be revisited to balance the ideal database implementation versus the realities of budgets and schedules. 关系数据库的结构 关系模型是任何关系数据库管理系统(RDBMS)的基础。一个关系模型有 二个核心组件:对象或关系的集合,作用于对象或关系上的操作,以及数据 完整性规则。换句话说,关系数据库有一个存储数据的地方,一种创建和检 索数据的方法,以及一种确认数据的逻辑一致性的方法。 一个关系数据库使用关系或二维表来存储支持某个事物所需的信息。让 我们了解一下一个传统的关系数据库系统的基本组件并目学习如何设计一个 关系数据库。一旦你对于行、列、表和关联是什么有了深刻理解,你就能够 充分发挥关系数据库的强大功能。 表,行和列 在关系数据库中,一个表(或者说一个关系)是一个用于保存相关信息的 二维结构。一个数据库由一个或者多个相关联的表组成。 注意:不要混淆了关系和关联。一个关系实际上是一个表,而一个关联 指的是一种连接、结合或联合两个表的方式。 表中的一行是一种事物的集合或实例,比如一个员工或发票上的一项。 表中的一列包含了一类信息;而且行列交叉点上的数据,字段,即是能够用数 据库查询语言检索到的最小片信息。举个例子来说,一个员工信息表可能有 一个“名字”列,列中就包含所有员工的名字。数据是通过对行、列进行过滤 而从表中检索出来的。 主码、数据类型和外码 本篇文章均以假设的斯科特·史密斯的工厂为例,他是数据库的建立者和 企业的主办人。他刚开办了一个饰品公司并目想要使用关系数据库的几项基 本功能来管理人力资源部门。 关系:用来保存相关信息的一个二维结构(也就是表)。 注意:大多数斯科特的雇员都是雇自过去的从业者,他们中有些人在这 个领域己经有 20 年的经验了。出于雇用的目的,斯科特同意在新数据库中 维持新进员工最初的雇佣日期。 行:在一个数据库表中的一组单数据或多数据元素,用于描述一个人、 地方或事物。 列:列是数据库表的组件,它包含所有行中同名和同类型的所有数据。 你会在下面章节学到如何设计数据库,现在让我们假设数据库大部分己 经设计完成并且有一些表需要被执行。斯科特创建了 EMP 表来保存基本的 员工信息,就像这样: 你可能注意到佣金列和管理人列中有一些单元格中没有值;它们是空值。 一个关系数据库能够规定列中的一个单元格是否为空。如此,可以明确那些 非销售部的员工佣金单元为空。同样也明确了公司董事长的管理人单元为空 , 因为这个员工不需要向任何人汇报工作。
温馨提示:当前文档最多只能预览 3 页,此文档共7 页,请下载原文档以浏览全部内容。如果当前文档预览出现乱码或未能正常浏览,请先下载原文档进行浏览。
发表评论(共0条评论)
请自觉遵守互联网相关政策法规,评论内容只代表网友观点,发表审核后显示!

下载需知:

1 该文档不包含其他附件(如表格、图纸),本站只保证下载后内容跟在线阅读一样,不确保内容完整性,请务必认真阅读

2 除PDF格式下载后需转换成word才能编辑,其他下载后均可以随意编辑修改

3 有的标题标有”最新”、多篇,实质内容并不相符,下载内容以在线阅读为准,请认真阅读全文再下载

4 该文档为会员上传,版权归上传者负责解释,如若侵犯你的隐私或权利,请联系客服投诉

返回顶部