B
B
BestJS2017-05-09 15:57:31
JavaScript
BestJS, 2017-05-09 15:57:31

How to properly organize relationships between tables in PostgreSQL?

There is a table with tracks, and a table with artists.
One track can have multiple artists.
I had two ideas:
1) In the table with the track, make a column with an array in which there will be id artists.
2) Make a separate table with three fields: id, track_id,
artist_id

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
antpv, 2018-07-05
@ivansimonov1984

You increment the value of the countFieldValue variable inside the changeCount function, but you don't change the value of value in the DOM. I added a render function that will update the value on click. It is better of course to do it right inside the handlers.

function render() {
    countField.value = countFieldValue;
}

countMinus.addEventListener('click', function() {
    countFieldValue--;
    render()
});

countPlus.addEventListener('click', function() {
    countFieldValue++;
    render()
});

E
entermix, 2017-05-09
@BestJS

artists
id, name, ...
tracks
id, name, ...
artists_tracks
artist_id, track_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question