ann
Member
Joined: 10/30/2006 17:38:56
Messages: 62
Offline
|
What is an Entity Relationship Diagram (ER or ERD or MyEclipse MER file)?
It is a diagram that shows the relationships between the entities in a data base. Usually this means between the tables in a data base.
Usually each table is represented, though some tools let you select which tables to include in the diagram. This is especially helpful with large databases.
The primary key to the table is highlighted. My Eclipse puts a yellow key in front of the key field(s). (see http://www.randrinc.com/2d_randr/files/Entity_Relationship_Diagram.pdf 2nd Diagram) Foreign keys are also highlighted. My Eclipse puts a blue key in front of a foreign key. Foreign keys are the links between the tables. This is your sql join statement. (Example, select w.url, w.description, w.prospect_id, p.customer_company from website w left join prospect p on w.prospect_id= p.prospect_id).
In the example below from Randr's Salesportal database (available on Sourceforge or at http://www.2d-salesportal.com) . Web_site is a table. The primary key to the table is web_site_id. The table also has one foreign keys: prospect_id. The blue lines join show the join between the web_site table and the table it is linked to: prospect.
The foreign key prospect_id in web_site is linked to the primary key in prospect. Note, that the name are the same but they do NOT have to be. You can have an unlimited number of foreign keys.
When you are creating a database keep that in mind. You will thank yourself later if you keep the naming consistent. Another convention you might see is to add fk(foreign key) to the column name. For example, you might see document_fk or document_id_fk as the name of a foreign key that links to the document_id key in the document table. I find that a little redundant, though I confess we did do that sometimes.
The links between the tables.
My Eclipse puts an arrow on the line pointing from the primary table to the linked table (see below) Also it shows the linking column on the line so it make it easy to see which line is which. In addition to showing the links between the tables, the lines show if it is one-to-many, many-to-many, many-to-one or one-to-one. This is shown by the symbol where the line joins the table symbol. In this case the link between document and prospect_document is one-to-many. One document can be linked to many prospects.
In addition in front of the symbol will either be | or o. The | means the record is required. The o means optional.
(see http://www.randrinc.com/2d_randr/files/Entity_Relationship_Diagram.pdf 1st Diagram)
The table is from the My Eclipse ER (Entity Relationship) Designer Tutorial. Here is the link:
http://www.myeclipseide.com/documentation/quickstarts/erdesigner
I like the Entity Relationship Diagram because it gives me a good visual snap shot of what the database looks like and how things are linked. I normally print the MER file from My Eclipse to a PDF and then print it out and tape the pages together to get the whole view.
Hope this is helpful. Ann Richmond, ann@randrinc.com.
|