国内最大的酷站演示中心!
word underlined is primary key
rule 1.each entity in an e-r diagram is mapped to a single table in a relational database;the table is name after the entity.the columns of the table represent all the single-valued simple attributes that are attached to the entity(possibly through a composite attribute,although a composite attribute itsself does not become a column of the table)。
rule2:given an entity e with primary identifier p,a multi-valued attribute a attached to e in an e-r diagram is mapped to a table of its own;the table is named after the plural multi-valued attribute.the columns of this new table are named after p and a,and rows of the table correspond to (p,a) value pairs,representing all pairings of attribute values of a associated with entity occurrences in e.the primary key attribute for this table is the set of columns in p and a.
eg: (here p = = eid,a == hobby)
employes(eid,staddress,city,states,zipcodes) (197,7 beacon,boston,ma,02102) (221,19 brighton st,boston,ma,02103)
hobbies(eid,hobby) (197,chess)(197,painting)(221,reading)
rules3:n-n relationships.when two entities e and f take part in a many-to-many binary relationship r,the relationship is mapped to a representative table t in the related relational database design.the table contains columns for all arrtibutes in the primary keys of both tables transformed from entities e and f,and this set of columns forms the primary key for the table t.
eg:(employees -(1,n)-works_on-(0,n)-projects ---n-n(many-to-many) )
employees(eid,straddr,city,state,zipcode) --woks_on(eid,prid,percent) --projects(prid,proj_name,due_date)
rules4:n-1 relationships.when two entities e and f take part in a many-to-one binary relationship r,the rlationship will not be mapped to a table of its own in a relational database design.instead,if we assume that the entity f has max-card(f,r)=1 and thus represents the “many“ side of the relationship,the relational table t transformed from the entity f should include colums constituting the primary key for the table transformed from the entity e;this is known as a foreign key in t.
eg:instructors(insid,lname,office_no,ext) -- cours_sections(secid,insid,course,room,preriod).
rules5:1-1 relationships,optional participation.given two entities e and f that take part in a one-to-one binary relationship r,where participation is optional on either side,we wish to translate this situation into a relaional design -- use foreign key on either or both sides.
rules6:1-1 relationships,mandatory participation on both sides. in the case of a one-to-one relationship with mandatory particpation on both sides,it is most appropriate to combine the tables for the two entities into one,and in this way avoid any foreign keys.