Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View Results provides incorrect results #3

Open
gdsotirov opened this issue Aug 26, 2021 · 0 comments
Open

View Results provides incorrect results #3

gdsotirov opened this issue Aug 26, 2021 · 0 comments

Comments

@gdsotirov
Copy link
Owner

View Results provides incorrect results in columns TCountry, DCountry and Drivers. For example:

mysql> SELECT * FROM Results WHERE Team LIKE '%Thistlethwayte%';
+------+-----+-------+-------+-----------------+---------------------------------------------+-----------------+---------------------------------------------------------------------+-----------------------------+-----------------+--------+------+----------+--------------+----------------------+
| Race | Pos | Class | CarNb | TCountry        | Team                                        | DCountry        | Drivers                                                             | Chassis                     | Engine          | Tyre   | Laps | Distance | RacingTime   | Reason               |
+------+-----+-------+-------+-----------------+---------------------------------------------+-----------------+---------------------------------------------------------------------+-----------------------------+-----------------+--------+------+----------+--------------+----------------------+
| 1926 | DNF | 3.0   |     9 | GBR|GBR|GBR|GBR | Bentley Motors Limited|Tommy Thistlethwayte | GBR|GBR|GBR|GBR | Tommy Thistlethwayte|Tommy Thistlethwayte|Clive Gallop|Clive Gallop | Bentley 3 Litre S |er Sport | Bentley 3.0L S4 | Dunlop |  105 | 1812.510 | 00:00:00.000 | Engine (rocker arm)
+------+-----+-------+-------+-----------------+---------------------------------------------+-----------------+---------------------------------------------------------------------+-----------------------------+-----------------+--------+------+----------+--------------+----------------------+

The information is duplicated, because the view joins many tables and multiplies the results when joining teams and drivers:

       LEFT JOIN  driver_results  DR  ON DR.result_id   = RES.id
       LEFT JOIN  drivers         D   ON DR.driver_id   = D.id
       LEFT JOIN  team_results    TMR ON TMR.result_id  = RES.id
       LEFT JOIN  teams           TM  ON TMR.team_id    = TM.id

Column Team is not affected, because it uses DISTINCT. This could be applied on the other columns, but it would lead to countries list being shrunk while it should not (e.g. GBR|GBR|GBR|GBR above, should be GBR|GBR not just GBR).

gdsotirov added a commit that referenced this issue Aug 26, 2021
Show only unique driver names. An initial fix for #3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant