Tag Info

New answers tagged

9

The query results are correct, as your query finds all teams and results where a team played against itself (home_team = away_team). You probably want to use 2 joins to teams in you query: SELECT home.team_name AS home_team_name, away.team_name AS away_team_name, r.score FROM results AS r JOIN teams AS home ON r.home_team = ...


3

There is always at least something else you should also know and almost equally, always something else you should be consciously putting a stop to. Specifically in the context of data warehousing, which is a relatively fledgling sector, leveraging relatively new technologies. In regards to what I've seen in the real world, walking into a company for the ...


2

You cannot add the constraints to tblUserRoles because the data within this table already violates the constraints that you are trying to add. a) Double check that all UserID values in tblUserRoles reference UserID values in tblUsers b) Do the same as the above for tblRoles and RoleID. c) As I imagine both of the above will return records that are not in ...


1

You need a key on passering.starttid in order to link it as a foreign key. Like this: CREATE TABLE passering ( avstand INT NOT NULL, starttid INT NOT NULL, slutttid INT NOT NULL, passeringspunkt INT NOT NULL, h√łydeforskjell VARCHAR(25) NULL, bilde VARCHAR(25) NOT NULL, mellomtid VARCHAR(25) NOT NULL, PRIMARY KEY ...


1

This behavior (allowing NULL values in FK columns) conforms to the SQL standard. Per Postgres manual: The CREATE TABLE command conforms to the SQL standard, with exceptions listed below. And there is no exception listed for FK constraints. To disallow that some columns of a multi-column FK are NULL, use MATCH FULL instead of the default MATCH SIMPLE ...


0

It is not possible to update the multiple tables interlinked with foreign keys. The constraints in MySQL only updates the related column. Hope this helps!


2

If you are sure enough that all constraints would be met..You can think off turning off the foreign key checks and after making sure that all constraints are ok, you can turn on foreign key checks. You can write a script to verify that if all constraints are ok. use following to turn off foreign key checks set foreign_key_checks=0 use following ...


2

Foreign keys are not required in order to execute a JOIN. Foreign keys are restrictions that are there for security reasons (so that you cannot change the value of a column, or delete/insert a row ending up with an inconsistent state between tables). It is true that in most cases foreign key are used as JOIN matching conditions. The reasons why InnoDB is ...



Top 50 recent answers are included