MySQL Many relational problems
source link: https://www.codesd.com/item/mysql-many-relational-problems.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
MySQL Many relational problems
I have 3 tables in mysql artists
tracks
and artist_tracks
and i did what was written in this aricle.
this is the tables artist
:artist_id, artist_name tracks
:track_id, track_name artist_tracks
: artist_id
, track_id
how can i prevent duplicate rows in artist_tracks
table ??
Create a composite primary key around both the artist_id
and track_id
columns. This is standard practice for bridge tables.
ALTER TABLE artist_tracks DROP PRIMARY KEY;
ALTER TABLE artist_tracks ADD PRIMARY KEY (artist_id, track_id);
If you followed that article correctly, you should already have such a key and so duplicates will be impossible.
Related Articles
C # LINQ to entities One-To-Many Relation: Problem displaying the latest log entry data
Mysql Many-Many Relationships
MySQL many to many relationship table
The entity frame has several-to-many relation table created & ldquo; backwards & rdquo;
Is it possible to increase the memory of a table? and related problem
Apache2 / http + MySQL / Wordpress loading problem related to socket delay
MySQL - Many to Many - Weighting / Ordering Relation Table Lines - Rebuilding Order When Relationships Are Divided
Problem with Linq2Sql Many-to-Many Relation & Insert new objects
MySQL: many joins and relations on the same table (theoretical question)
MySQL much to many relational matching
Trying to understand the logic of complex SQL queries in MySQL and relational algebra
Flex 4, Spring 3 with Hibernate & amp; MySQL configuration + configuration problems
MySql Java: strange problem that I can not solve
Laravel Eloquent: Query for attribute in Many-To-Many Relation
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK