Relationships are widely used in database software. Linking forms is the best way to avoid big table creation
In order to make the created online database fully functional, easy-to-work and comfortable for a user as much as possible, very often it is necessary to ensure a mutual relationship between two or three and sometimes even more tables containing data.
If it is not done, then after all you will have to enter one and the same information into several fields. This is extremely inconvenient due to the following two reasons: possibility to enter wrong data increases and time expenditures for database servicing grow.
The developers of the database with a web access MyTaskHelper have provided for it by introduction of a Database Relationships function into the system. In order to see how this function works and study to use it we will consider one example of linking two tables: “Teams” and “Players”. The first one contains information about club names (name, kind of sport, city, league, rating, etc.) and the second one contains information about teams’ composition.
After fields addition, tables creation and filling the tables with all necessary information a new window, in which the method of fields table linking is determined, appears in the menu (option “Forms”/ “Relationship”). There are four relationship types there: “have one” (one relationship), “have many”, “belong to many” and just “belong”. Let’s consider how the tables are linked in relation to some of these types.
Forming such a type one has to take into account the following reasoning: a club has many players and a player can belong to only one club. According to it there is a field with a list next to the name of every participant of the club, but one can choose only one particular club in the list. Together with this, a user, when entering the information about a new player, has a possibility to indicate the club to which this player belongs to at once. Besides, if you, after relationships formation, choose a link to the club you are interested in and “Show related records” menu button you can see the names of all players of the club. By no means unimportant is the fact that these records can be sorted and exported to Excel.
Belong to many
Here there is a little bit different reasoning: there are many players in a team and each of them may belong to several teams simultaneously. In fact, the process of relationships creation is similar to the previous one with one addition: one can indicate several teams for one player in the drop-down list. The fields are exactly the same; there is a list of players next to the list of clubs and there is a drop-down list of clubs and information about them next to the list of players.
Here we will join three tables of our relational database; and for this we will add one more additional table containing records about coachers. Inherently, every coacher has one team and every team has one coacher. Things are rarely different in sport, though exceptions may take place if a club coacher works with a national team as well. But we do not consider national teams in our example.
In our example we will ensure a relationship between two tables – “Teams” and “Coachers” and we will use “Team name” field as a connection. Following the reasoning of such relationships formation there is a field with a list, which makes it possible to choose only one club, next to the name of every coacher. Similar to it is a reverse variant: there is a field with a name of only one coacher next to the name of every team. Having done all the above-mentioned operations we will get a very good picture. Choosing any team one can see fields with the main information about it, name of the coacher and its composition. If we choose a player, we can see all the information about his coacher and the team he plays.
And test question. What will you see if you choose the name of the coacher?