Music collection database design

Discuss the database features
Post Reply
OldMan63
Posts: 12
Joined: Wed Jul 28, 2021 5:20 pm

Music collection database design

Post by OldMan63 »

Hello All,

Just made a Database of music collection by my self. I don't know if it's alright.
So, please, any adjustments are welcome. It is a simple one.

Han

 Edit: Changed subject, was Music Col. new 
Make your post understandable by others 
-- MrProgrammer, forum moderator 
Attachments
Nieuwe Database.odb
(14.17 KiB) Downloaded 193 times
Open Office 3.1 on Linux Mint 20.2
Bidouille
Volunteer
Posts: 577
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: Music Col. new

Post by Bidouille »

Please provide a database in english, this is more easy to understood here.

As I see, the relation 1-n between artiste and song is wrong
Because a song could be sing by more artists.
capture.jpg
capture.jpg (19.78 KiB) Viewed 4139 times
User avatar
floris v
Volunteer
Posts: 4431
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: Music Col. new

Post by floris v »

If artist really means creator/composer of a song, a 1-n relation is fine. If you also have covers of a song, you will get into trouble.

It's your database. You know what information you will want to store there, we don't. So, instead of posting your database here, it makes more sense to post a diagram or something like that, containing all the elements that you want to include. Like, for bands: names and other personal data of the members; other information about the bands; the highest ranking in some Top 10, Top 100 or top 2000 hit lists, etc. Then the database experts can advise you about what data type you should use, how to organize your tables and so on.
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
OldMan63
Posts: 12
Joined: Wed Jul 28, 2021 5:20 pm

Re: Music collection database design

Post by OldMan63 »

For All,
This is a new design, in english, sorry about that. My music database is small, because I'm only interrest in the artist and songs I have. Not in any Top40-50-100 position.
If it's wrong, please make any adjustments or tell me how I can make things the right way.

Han
New Music.odb
(3.6 KiB) Downloaded 190 times
New Music.odb
(3.6 KiB) Downloaded 190 times
Open Office 3.1 on Linux Mint 20.2
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Music collection database design

Post by RPG »

If you are the same person as in this thread Muziek ja de zoveelste - (Bekijk onderwerp) on the Dutch forum then it is maybe better to explain what you already have. Maybe in this forum are people who can tell you how to convert it.

Maybe you can place here some parts of your real spreadsheets
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
OldMan63
Posts: 12
Joined: Wed Jul 28, 2021 5:20 pm

Re: Music collection database design

Post by OldMan63 »

Yes.
My real spreadsheet is very big. Lots of data.

Han
Open Office 3.1 on Linux Mint 20.2
Nick N,
Posts: 140
Joined: Wed Aug 09, 2023 2:10 pm

Re: Music collection database design

Post by Nick N, »

Should it be of interest to you, take a look here viewtopic.php?p=542159#p542159.

Please find odb file Old Music attached hereto.

With very best regards

Nick
Attachments
Old music.odb
(21.67 KiB) Downloaded 190 times
Libre Office 6.0.7 on Ubuntu 18.04
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Music collection database design

Post by Villeroy »

Nick N, wrote: Wed Nov 08, 2023 10:10 pm Please find odb file Old Music attached hereto.
The same song interpreted by different artists never has the same length.
I would use a single song list with artist name and time.

Code: Select all

CREATE TABLE SONGS(
  N VARCHAR_IGNORECASE(100) NOT NULL,
  A VARCHAR_IGNORECASE(100) NOT NULL,
  T time not null,
  id int identity
);
A play list should have a name and some date (creation date or performance date or both).

Code: Select all

create table PL(
  N varchar(20),
  CD date default current_date,
  PD date,
  ID int identity
);
If each song may belong to any play list and vice versa, this is a many-to-many relation with a mapping table.

Code: Select all

create table PL_S(
  PLID int, 
  SID int, 
  ORD int, 
  primary key (PLID, SID), 
  foreign key (PLID) references PL (ID), 
  foreign key (PLID) references SONGS (ID)
  );
The ORD column can be used to specify an order of appearance.
The above statements create a database with relations when copied into the SQL window and executed. Call menu:Data>"Refresh Tables" after doing so.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Nick N,
Posts: 140
Joined: Wed Aug 09, 2023 2:10 pm

Re: Music collection database design

Post by Nick N, »

Mr. Villeroy's comment: The same song interpreted by different artists never has the same length.
I would use a single song list with artist name and time.
.

Sorry for distraction:

Code: Select all

ALTER TABLE Playlist ADD Timing MINUTE_SECOND;

Code: Select all

SELECT "Playlist"."ID_Playlist", "Playlist"."date", "Artist"."name", "Songs"."title", "Playlist"."time" FROM "Playlist", "Artist", "Songs" WHERE "Playlist"."ID_Artist" = "Artist"."ID_Artist" AND "Playlist"."ID_Song" = "Songs"."ID_Song"
here is the update.

Regards

Nick
Attachments
Old music0001.odb
(21.94 KiB) Downloaded 184 times
Libre Office 6.0.7 on Ubuntu 18.04
Bidouille
Volunteer
Posts: 577
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: Music Col. new

Post by Bidouille »

floris v wrote: Tue Nov 07, 2023 3:52 pmIf artist really means creator/composer of a song, a 1-n relation is fine.
Nirvana – In Utero
Song: Scentless Apprentice
Music By – Dave Grohl, Krist Novoselic, Kurt Cobain
Words By – Kurt Cobain
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Music collection database design

Post by RPG »

As far I know does have OldMan63 a spreadsheet with 5000 records.
A new example short example you can find here: Ja, weer de muziek collectie

Maybe it is possible to use the spreadsheet for the database or copy the data in a new database.
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Nick N,
Posts: 140
Joined: Wed Aug 09, 2023 2:10 pm

Re: Music collection database design

Post by Nick N, »

@ Bidouille

...And I swear that I don't have a gun (phrase by Kurt Cobain)

@ RPG

Just give me a five dollar bill and a floor shine shoes (phrase by Frank Zappa)

Regards

Nick
Libre Office 6.0.7 on Ubuntu 18.04
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Music collection database design

Post by Villeroy »

RPG wrote: Thu Nov 09, 2023 11:12 am As far I know does have OldMan63 a spreadsheet with 5000 records.
A new example short example you can find here: Ja, weer de muziek collectie

Maybe it is possible to use the spreadsheet for the database or copy the data in a new database.
Of course it is possible to copy cell values from a spreadsheet into a database.

First of all, the database should be ready made with all tables and relations because changing the structure of a populated database can be rather difficult.
Then you have 2 options:
- Copy spreadsheet data as a temporary table(s) into the database and use the SQL language to populate the actual tables with valid data.
- Use Calc to generate valid row sets that can be copied directly from sheet to table. You have to test if data are consistent and complete, otherwise the database may reject data.

I see the spreadsheet "Map1.ods" with the first sheet having artists and titles as flat text with no relation to any other table. In this particular case, I would stick to that "main table" without splitting artists or titles into separate tables.
Store the titles and artist names as VARCHAR_IGNORECASE and add indices on these fields. This makes it easier and faster to search through the text.
For the genres, you should ask yourself if some piece of music is associated to one distinct genre (one-to-many) or if multiple genres should be possible (many-to-many) or if you just need some text column with searchabel keywords. The latter is not convenient to get razor sharp statistics from.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Music collection database design

Post by RPG »

Villeroy wrote: Thu Nov 09, 2023 12:31 pm I see the spreadsheet "Map1.ods" with the first sheet having artists and titles as flat text with no relation to any other table. In this particular case, I would stick to that "main table" without splitting artists or titles into separate tables.
Store the titles and artist names as VARCHAR_IGNORECASE and add indices on these fields. This makes it easier and faster to search through the text.
I have later changed sheet "VB Table" a little: I have delete the empty column. It seems to me that the Column "Artist/Group" and "Country" are a kind of relations. I have the idea they can be used in forms; master/slave fields.
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Music collection database design

Post by Villeroy »

Code: Select all

create table countries(
  code char(3) not null primary key,
  name varchar(50) not null
);
create table titles(
  artist varchar_ignorecase(200) not null, 
  title varchar_ignorecase(200) not null, 
  t time not null,
  y smallint not null,
  cid char(3) not null,
  id int identity,
  foreign key (cid) references countries (code)
);
create table genres(
  n varchar(30),
  id int identity
);
create table g_t(
 gid int, tid int, 
 primary key (gid, tid),
 foreign key (tid) references titles (id),
 foreign key (gid) references genres (id)
);
By default, I made all columns mandatory (not null).
We can not know exact lenghts of the varchar fields without original data.
=MAX(LEN(A1:A9999)) [Ctrl+Shift+Enter] returns the max. length of text in A1A9999
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Nick N,
Posts: 140
Joined: Wed Aug 09, 2023 2:10 pm

Re: Music collection database design

Post by Nick N, »

@ Oldman63

Ok, by transferring your data from the spreadsheet, I have copied the Artists in one table first, then the Songs in a second one. Had also to create CONSTRAINTS.

To make stuff work under a database in order to future artists and songs addition, I've add to create relations between following tables: Artists 1---n Playlist n----1 Songs (this to resolve a many-to-many relationship).

You may have a glance by double clicking on Query1.

Three Forms are at your disposal, I.E. :
Registration
Build Playlist (fake)
Read Playlist.

Since Libre Office Base does not let me do table creation by coding, but by GUI interface instead, I did it this way.

Feel free to post comments.

Regards

Nick
Attachments
OldMusic.odb
(31.29 KiB) Downloaded 190 times
Libre Office 6.0.7 on Ubuntu 18.04
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Music collection database design

Post by Villeroy »

A flat database table "TITLES" with a filter form.
In the titles table only the keywords column (KW) is optional.
Attachments
music_flat.odb
(17.3 KiB) Downloaded 207 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply