Know How to Read an ER Model

From WikiContent

(Difference between revisions)
Jump to: navigation, search
Current revision (17:05, 22 January 2010) (edit) (undo)
 
(One intermediate revision not shown.)
Line 1: Line 1:
-
Software applications store data in databases. Database administrators, system architects and developers design the database layout. The ER model is the visual of how the data is stored. An ER model is an entity relationship model.
+
Reading a data model is like reading a map; most elements of a map are instantly recognizable and give the viewer a visual sense of where they are. In databases, the Entity-Relationship (ER) model gives the viewer a visual sense of the data model. Reading an ER model, like reading a map, can be done just for basic information and then, as you become accustomed to reading, you can look deeper for the finer intricacies of the model.
-
Being able to read and ER model is like reading a map; some elements of a map are more readily understandable than others. Learning to read an ER model is like other information we learn; it helps to start with an overview and continue learning with understanding the finer points and intricacies.
+
The "E" of the ER model refers to ''entity''; an entity is also referred to as a table. The tables in a database store the data. For example, imagine a database that stores customer information. The tables in a customer database might consist of a customer table, an address table and a phone number table. Each table contains one or more columns.
-
An entity is also referred to as a table, and tables store data. For example, imagine a database that stores customer information. The tables in a customer database might consist of a customer table, an address table and a phone number table. Tables contain one or more columns, and, using our customer database example, the columns on a customer table might include: company name, company website and company president. The address table might include these columns of data: street name, suite number, city, state and zip code. On the ER diagram, there would be a rectangle with the name "Customer" just above it, and the columns would appear inside the rectangle.
+
The "R" of the ER model refers to the ''relationships'' the tables have to each other. Imagine a database that stores customer and sales information. The customer table would have a relationship to the sales tale. In order to tie the two tables together and join the information, a column in the sales table must contain a reference to the associated customer. These table relationships are shown on an ER model, which in this case would be a line between the customer and sales tables.
-
The 'R' of the ER model refers to the the relationships which the tables have to each other. For example, a table containing customer data will have a relationship with the table containing orders data (customers place orders), which means that a row in the orders table must contain a reference to the associated customer who placed the order. This relationship will appear on the ER diagram as a line between the two tables.
+
As a map shows places, an ER model shows tables. Once you become comfortable reading the tables on an ER model, a next level of understanding is reading the relationships. As a map shows us how to navigate from one place to another, an ER model shows how the tables relate to one another. Primary keys and foreign keys are two types of relationships usually shown on an ER model.
-
As each company gets added or created through the application, a row of information for that company gets added to the tables. Columns and rows in a database can be compared to an Excel file where the column headers represent what data is stored and each row of the spreadsheet represents the data itself. Tables in a database are made up of columns and rows.
+
A primary key is used to uniquely identify each row in each table. The primary key is comprised of a single column or, less frequently, a set of columns. No two rows can have the same value for the primary key. An example would be using the customer name field as the primary key on the customer table.
-
A primary key is used to uniquely identify each row in each table. The primary key is comprised of a single column or set of columns. No two rows can have the same value for the primary key. An example would be using the customer name field as the primary key on the customer table.
+
-
A foreign key is a referential constraint between two tables. The foreign key identifies a column or a set of columns as a reference to another table. Using the customer database example, a column on the address table is needed to refer back to the customer table. This relationship links the data and the tables together.
+
A foreign key is a referential constraint between two tables. The foreign key identifies a column or a set of columns as a reference to another table. Using the customer database example, a column on the address table is needed to refer back to the customer table. Foreign keys link data and tables together.
-
Having a sense of the data model is like knowing the primary highways through a state or province. Once you get familiar with reading a data model, you’ll find you won’t want to work on an application without seeing the model. It would be like leaving your house without at GPS or road atlas – the data model is navigation tool into the inner working of an application.
+
 
 +
Having a sense of the data model is like knowing the primary highways through a state or province. Once you get familiar with reading a data model, you’ll find you won’t want to work with an application without seeing the ER model. It would be like leaving your house without at GPS or road atlas – the data model is the navigation tool into the inner working of an application and its data.

Current revision

Reading a data model is like reading a map; most elements of a map are instantly recognizable and give the viewer a visual sense of where they are. In databases, the Entity-Relationship (ER) model gives the viewer a visual sense of the data model. Reading an ER model, like reading a map, can be done just for basic information and then, as you become accustomed to reading, you can look deeper for the finer intricacies of the model.

The "E" of the ER model refers to entity; an entity is also referred to as a table. The tables in a database store the data. For example, imagine a database that stores customer information. The tables in a customer database might consist of a customer table, an address table and a phone number table. Each table contains one or more columns.

The "R" of the ER model refers to the relationships the tables have to each other. Imagine a database that stores customer and sales information. The customer table would have a relationship to the sales tale. In order to tie the two tables together and join the information, a column in the sales table must contain a reference to the associated customer. These table relationships are shown on an ER model, which in this case would be a line between the customer and sales tables.

As a map shows places, an ER model shows tables. Once you become comfortable reading the tables on an ER model, a next level of understanding is reading the relationships. As a map shows us how to navigate from one place to another, an ER model shows how the tables relate to one another. Primary keys and foreign keys are two types of relationships usually shown on an ER model.

A primary key is used to uniquely identify each row in each table. The primary key is comprised of a single column or, less frequently, a set of columns. No two rows can have the same value for the primary key. An example would be using the customer name field as the primary key on the customer table.

A foreign key is a referential constraint between two tables. The foreign key identifies a column or a set of columns as a reference to another table. Using the customer database example, a column on the address table is needed to refer back to the customer table. Foreign keys link data and tables together.

Having a sense of the data model is like knowing the primary highways through a state or province. Once you get familiar with reading a data model, you’ll find you won’t want to work with an application without seeing the ER model. It would be like leaving your house without at GPS or road atlas – the data model is the navigation tool into the inner working of an application and its data.

Personal tools