I it relationship examples database

One-to-one relationships

i it relationship examples database

Once a database is normalized, relationships between the data in multiple Return to your sample tables and start entering foreign keys as. Entity Relationship Modeling Examples Earlier in this chapter, we showed you how to design a database and understand an Entity Relationship (ER) diagram. In a one-to-many relationship, one record in a table can be associated with one or more records in another table. For example, each customer can have many sales orders. A one-to-many Related topics. Planning a relational database.

i it relationship examples database

In the above example, we could just as easily have put an HourlyRate field straight into the Employee table and not bothered with the Pay table. However, hourly rate could be sensitive data that only certain database users should see. So, by putting the hourly rate into a separate table, we can provide extra security around the Pay table so that only certain users can access the data in that table. One-to-Many or Many-to-One This is the most common relationship type.

One-to-one relationships

In this type of relationship, a row in table A can have many matching rows in table B, but a row in table B can have only one matching row in table A. Example of one-to-many relationship. One-to-Many relationships can also be viewed as Many-to-One relationships, depending on which way you look at it. Each customer can only be assigned one city. One city can be assigned to many customers.

Many-to-Many In a many-to-many relationship, a row in table A can have many matching rows in table B, and vice versa.

i it relationship examples database

A many-to-many relationship could be thought of as two one-to-many relationships, linked by an intermediary table. This table is used to link the other two tables together.

News, Tips, and Advice for Technology Professionals - TechRepublic

It does this by having two fields that reference the primary key of each of the other two tables. The following is an example of a many-to-many relationship: This is the Relationships tab that is displayed when you create a relationship Microsoft Access. In this case, a many-to-many relationship has just been created. 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.

i it relationship examples database

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.

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.

i it relationship examples database

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. 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.

i it relationship examples database

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.

  • One-to-many relationships
  • Learning MySQL by Hugh E. Williams, Saied M.M. Tahaghoghi
  • Relational databases: Defining relationships between database tables

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. Each flight is carried out by a single airplane.

A passenger has given names, a surname, and a unique email address. A passenger can book a seat on a flight. The ER diagram of the flight database An Airplane is uniquely identified by its RegistrationNumber, so we use this as the primary key.

A Flight is uniquely identified by its FlightNumber, so we use the flight number as the primary key.