I’m in Oracle APEX and would like to create a new table from other existing one like this:
I have a column in a SONGS table that is:
ARTIST NAME | Another header |
---|---|
Bad Bunny | row |
Bad Bunny, Ozuna, Daddy Yankee | row |
And I want this in another table:
ID | Artist |
---|---|
1 | Bad Bunny |
2 | Ozuna |
3 | Daddy Yankee |
Also, from these 2 tables I would like to create another table or relationship to indicate on what songs have an artist participated.
Something like:
Song ID | Artist ID |
---|---|
1 | 1 |
2 | 1 |
2 | 2 |
I want this third table to know in what song has participated an artist.
So im having troubles to create the 2nd and 3rd table from the first table.
Advertisement
Answer
These are actually 2 different issues in a single question. Treat them as 2 different issues.
- How to design your tables. This needs to be done first, you can import your data in them later. Create a songs table, an artist table and an intersect table (artist_songs) with foreign keys to both artists and songs. It should be pretty straightforward, there are thousands of examples on the web or, since you’re using apex, using quicksql (SQL WOrkshop > Utilities > quick sql) for generating the tables is also an option.
- Migrate the data from that base table into your new, normalized tables. Have a look at this similar stackoverflow question
You have provided very little info about what data you have available initially. It only shows artists in a comma separated form – it’s hard to say how you would populate the songs or intersect table with that info.