【正文】
or unique key column in another table. A foreign key assists in ensuring the data integrity of a table. Referential Integrity A method employed by a relational database system that enforces onetomany relationships between tables. Data Modeling 8 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 mon 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 datamodeling 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 plete, it is repeated as many times as necessary to ensure that the designer is capturing what is important enough to go into the database. Let39。s the DBA39。s widget pany database, he identifies four entities: employees, departments, salary grades, and bonuses. These will bee 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。s assume for the moment that the majority of the database design is pleted 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。 last names. Data is retrieved from a table by filtering on both the row and the column. 6 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 pany and wants to implement a few of the basic business functions using the relational database to manage his Human Resources (HR) department. Relation: A twodimensional structure used to hold related information, also known as a table. Note: Most of Scott39。s go over the basic ponents 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, you39。然而,一旦設(shè)計(jì)進(jìn)入到實(shí)際的運(yùn)作,數(shù)據(jù)庫(kù)管理員就會(huì)很快讓設(shè)計(jì)者從理想回到現(xiàn)實(shí)中來(lái)。當(dāng)我們?cè)诨仡欔P(guān) 聯(lián)時(shí),就會(huì)發(fā)現(xiàn)需要建立新的實(shí)體。而學(xué)生 _班級(jí)關(guān)系表中就包含了學(xué)生和班級(jí)之間的關(guān)系,以表明哪個(gè)學(xué)生在哪個(gè)班。這種關(guān)系不像一對(duì)多關(guān)聯(lián)那么常見(jiàn),因?yàn)槿绻粋€(gè)實(shí)體與另一個(gè)實(shí)體總有對(duì)應(yīng)行,在大多數(shù)情況下,兩個(gè)實(shí)體中的屬性只在一個(gè)實(shí)體內(nèi)出現(xiàn)就可以了。 一對(duì)一關(guān)聯(lián):在一個(gè)一對(duì)一關(guān)聯(lián)中,表中的一行只關(guān)聯(lián)另一個(gè)表中的一行甚至 0 行。 通常,關(guān)系數(shù)據(jù)庫(kù)間有二種關(guān)聯(lián)方式: 一對(duì)多關(guān)聯(lián):最常見(jiàn)的關(guān)聯(lián)是一對(duì)多關(guān)聯(lián)。如果事物間的關(guān)系原則是用來(lái)約束某個(gè)部門的工資水平的,就可能需要一個(gè)