Entity relationship diagram of a database

Entity Relationship Modeling Examples - Learning MySQL [Book]

entity relationship diagram of a database

What is an Entity Relationship Diagram (ERD)?. An entity relationship diagram ( ERD) shows the relationships of entity sets stored in a database. An entity in this . This definition explains the meaning of entity relationship diagram, also known as ERD, and how the data model can be used to design relational databases. The entity relationship (ER) data model has existed for over 35 years. It is well suited to data modelling for use with databases because it is fairly abstract and is .

Each track is on exactly one album. Each track has a time length, measured in seconds. When a track is played, the date and time the playback began to the nearest second should be recorded; this is used for reporting when a track was last played, as well as the number of times music by an artist, from an album, or a track has been played. Conversely, each play is associated with one track, a track is on one album, and an album is by one artist. The attributes are straightforward: The track entity has a time attribute to store the duration, and the played entity has a timestamp to store when the track was played.

If you wanted to use the music database in practice, then you might consider adding the following features: Support for compilations or various-artists albums, where each track may be by a different artist and may then have its own associated album-like details such as a recording date and time. Under this model, the album would be a strong entity, with many-to-many relationships between artists and albums. Playlists, a user-controlled collection of tracks.

For example, you might create a playlist of your favorite tracks from an artist.

Database Lesson #4 of 8 - Data Modeling and the ER Model

Track ratings, to record your opinion on how good a track is. Source details, such as when you bought an album, what media it came on, how much you paid, and so on. Album details, such as when and where it was recorded, the producer and label, the band members or sidemen who played on the album, and even its artwork. Smarter track management, such as modeling that allows the same track to appear on many albums. The University Database The university database stores details about university students, courses, the semester a student took a particular course and his mark and grade if he completed itand what degree program each student is enrolled in.

We explain the requirements next and discuss their shortcomings at the end of this section. Consider the following requirements list: The university offers one or more programs.

A program is made up of one or more courses.

  • Learning MySQL by Hugh E. Williams, Saied M.M. Tahaghoghi
  • What is Entity Relationship Diagram (ERD)?

A student must enroll in a program. A student takes the courses that are part of her program. A program has a name, a program identifier, the total credit points required to graduate, and the year it commenced.

A course has a name, a course identifier, a credit point value, and the year it commenced. Students have one or more given names, a surname, a student identifier, a date of birth, and the year they first enrolled.

When he finishes the course, a grade such as A or B and a mark such as 60 percent are recorded. Each course in a program is sequenced into a year for example, year 1 and a semester for example, semester 1. Although it is compact, the diagram uses some advanced features, including relationships that have attributes and two many-to-many relationships.

Entity–relationship model

The ER diagram of the university database In our design: Each student must be enrolled in a program, so the Student entity participates totally in the many-to-one EnrollsIn relationship with Program. A program can exist without having any enrolled students, so it participates partially in this relationship. As a weak entity, Course participates totally in the many-to-one identifying relationship with its owning Program. This relationship has Year and Semester attributes that identify its sequence position.

Student and Course are related through the many-to-many Attempts relationships; a course can exist without a student, and a student can be enrolled without attempting any courses, so the participation is not total.

When a student attempts a course, there are attributes to capture the Year and Semester, and the Mark and Grade. For a real university, many more aspects would need to be captured by the database. The airline has one or more airplanes. An airplane has a model number, a unique registration number, and the capacity to take one or more passengers. An airplane flight has a unique flight number, a departure airport, a destination airport, a departure date and time, and an arrival date and time.

entity relationship diagram of a database

Such an initial model can also be evolved into physical database model that aids the creation of relational database, or aids in the creation of process map and data flow model. In this section we will go through the ERD symbols in detail. Studentobject e. Invoiceconcept e. Profile or event e. In ERD, the term "entity" is often used instead of "table", but they are the same. When determining entities, think of them as nouns. In ER models, an entity is shown as a rounded rectangle, with its name on top and its attributes listed in the body of the entity shape.

Entity Attributes Also known as column, an attribute is a property or characteristic of the entity that holds it. An attribute has a name that describes the property and a type that describes the kind of attribute it is, such as varchar for a string, and int for integer.

What is Entity Relationship Diagram (ERD)?

The ER diagram example below shows an entity with some attributes in it. Primary Key Also known as PK, a primary key is a special kind of entity attribute that uniquely defines a record in a database table.

In other words, there must not be two or more records that share the same value for the primary key attribute. The ERD example below shows an entity 'Product' with a primary key attribute 'ID', and a preview of table records in database.

Foreign Key Also known as FK, a foreign key is a reference to a primary key in table. It is used to identify the relationships between entities. Note that foreign keys need not to be unique. Multiple records can share the same values. The ER Diagram example below shows an entity with some columns, among which a foreign key is used in referencing another entity.

Relationship A relationship between two entities signifies that the two entities are associated with each other somehow. For example, student might enroll into a course.

The entity Student is therefore related with Course, and the relationships is presented as a connector connecting between them. Cardinality Cardinality defines the possible number of occurrence in one entity which are associated to the number of occurrences in another. When present in an ERD, the entities Team and Player are inter-connected with a one-to-many relationship. In an ER diagram, cardinality is represented as a crow's foot at the connector's ends. The three common cardinal relationships are one-to-one, one-to-many, and many-to-many.

One-to-One cardinality example A one-to-one relationship is mostly used to split an entity in two to provide information concisely and make it more understandable. The figure below shows an example of one-to-one relationship. One-to-Many cardinality example A one-to-many relationship refers to the relationship between two entities X and Y in which an instance of X may be linked to many instances of Y, but an instance of Y is linked to only one instance of X.

The figure below shows an example of one-to-many relationship.

entity relationship diagram of a database