dbTalk Databases Forums  

How to create a 1 to 1 relationship or 1 to many...not sure

comp.databases.mysql comp.databases.mysql


Discuss How to create a 1 to 1 relationship or 1 to many...not sure in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
SM
 
Posts: n/a

Default How to create a 1 to 1 relationship or 1 to many...not sure - 03-08-2010 , 07:01 PM






Hello,
I'm trying to create a db model for a discography, for one artist.
I have a very basic model that i will improve with time.

Here's a summary of my model. I have approx. 4 databases:

album
disc
track
video

I decide it to separate tracks and videos because i will use those
tables later on the webpage (Videography and Lyrics section).

Basically, 1 album contains n discs and 1 disc is unique to 1 album;
that's a one to many relationship.
1 disc contains n (track or a video)

And 1 (track or video) appears on n disc.

I was able to create the relationship between 'album' and 'disc' but
i'm not sure how to proceed with the track and video table.

I thought of inserting the trackid or the videoid inside a new table;
'multimedia' and create a 'disc_multimedia' table... but it looks
heavy..

I need guidance and expertise.

Thanks in advance
Marco

Reply With Quote
  #2  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: How to create a 1 to 1 relationship or 1 to many...not sure - 03-08-2010 , 07:33 PM






SM wrote:
Quote:
Hello,
I'm trying to create a db model for a discography, for one artist.
I have a very basic model that i will improve with time.

Here's a summary of my model. I have approx. 4 databases:

album
disc
track
video

I decide it to separate tracks and videos because i will use those
tables later on the webpage (Videography and Lyrics section).

Basically, 1 album contains n discs and 1 disc is unique to 1 album;
that's a one to many relationship.
1 disc contains n (track or a video)

And 1 (track or video) appears on n disc.

I was able to create the relationship between 'album' and 'disc' but
i'm not sure how to proceed with the track and video table.

I thought of inserting the trackid or the videoid inside a new table;
'multimedia' and create a 'disc_multimedia' table... but it looks
heavy..

I need guidance and expertise.

Thanks in advance
Marco
I'm not sure if you're talking different types of disks (i.e. music cd's
and dvd's) or not, because it seems you're half-way mixing videos and
songs. I am assuming, of course, that a specific disk is not both a
music cd and a dvd.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #3  
Old   
SM
 
Posts: n/a

Default Re: How to create a 1 to 1 relationship or 1 to many...not sure - 03-08-2010 , 09:36 PM



On Mar 8, 7:33*pm, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
Quote:
SM wrote:
Hello,
I'm trying to create a db model for a discography, for one artist.
I have a very basic model that i will improve with time.

Here's a summary of my model. I have approx. 4 databases:

album
disc
* * *track
* * *video

I decide it to separate tracks and videos because i will use those
tables later on the webpage (Videography and Lyrics section).

Basically, 1 album contains n discs and 1 disc is unique to 1 album;
that's a one to many relationship.
1 disc contains n (track or a video)

And 1 (track or video) appears on n disc.

I was able to create the relationship between 'album' and 'disc' but
i'm not sure how to proceed with the track and video table.

I thought of inserting the trackid or the videoid inside a new table;
'multimedia' and create a 'disc_multimedia' table... but it looks
heavy..

I need guidance and expertise.

Thanks in advance
Marco

I'm not sure if you're talking different types of disks (i.e. music cd's
and dvd's) or not, because it seems you're half-way mixing videos and
songs. *I am assuming, of course, that a specific disk is not both a
music cd and a dvd.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================
That's exact. Some albums can contain a CD (or more) with tracks and a
DVD with videos. I dont' ever remember seeing a CD that contained a
video or a DVD that contained a track for this artist. In fact, i've
done some research on hundreds of albums on amazon.com and most of
them come with a second disc for the dvd video. I did see some
exceptions were a CD contained tracks and the last so call track was a
video... so it is possible.

In my model, i also have a table called 'format' that represents the
type of disc (CD, DVD, LP, EP, SINGLE, etc...). I've created a 1 to 1
relationship with 'disc' and 'format'.

The table 'tracks' contains all the tracks for this artist and the
table 'video' contains videos (not only the videos from this artist
DVDs but videos in general from this artist).

Hope this helps. Thanks again

Reply With Quote
  #4  
Old   
SM
 
Posts: n/a

Default Re: How to create a 1 to 1 relationship or 1 to many...not sure - 03-08-2010 , 09:40 PM



On Mar 8, 7:33*pm, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
Quote:
SM wrote:
Hello,
I'm trying to create a db model for a discography, for one artist.
I have a very basic model that i will improve with time.

Here's a summary of my model. I have approx. 4 databases:

album
disc
* * *track
* * *video

I decide it to separate tracks and videos because i will use those
tables later on the webpage (Videography and Lyrics section).

Basically, 1 album contains n discs and 1 disc is unique to 1 album;
that's a one to many relationship.
1 disc contains n (track or a video)

And 1 (track or video) appears on n disc.

I was able to create the relationship between 'album' and 'disc' but
i'm not sure how to proceed with the track and video table.

I thought of inserting the trackid or the videoid inside a new table;
'multimedia' and create a 'disc_multimedia' table... but it looks
heavy..

I need guidance and expertise.

Thanks in advance
Marco

I'm not sure if you're talking different types of disks (i.e. music cd's
and dvd's) or not, because it seems you're half-way mixing videos and
songs. *I am assuming, of course, that a specific disk is not both a
music cd and a dvd.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================
That's exact. Some albums can contain a CD (or more) with tracks and a
DVD with videos. I dont' ever remember seeing a CD that contained a
video or a DVD that contained a track for this artist. In fact, i've
done some research on hundreds of albums on amazon.com and most of
them come with a second disc for the dvd video. I did see some
exceptions were a CD contained tracks and the last so call track was a
video... so it is possible.

In my model, i also have a table called 'format' that represents the
type of disc (CD, DVD, LP, EP, SINGLE, etc...).

The table 'tracks' contains all the tracks for this artist and the
table 'video' contains videos (not only the videos from this artist
DVDs but videos in general from this artist).

Hope this helps. Thanks again

Reply With Quote
  #5  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: How to create a 1 to 1 relationship or 1 to many...not sure - 03-09-2010 , 05:46 AM



SM wrote:
Quote:
On Mar 8, 7:33 pm, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
SM wrote:
Hello,
I'm trying to create a db model for a discography, for one artist.
I have a very basic model that i will improve with time.
Here's a summary of my model. I have approx. 4 databases:
album
disc
track
video
I decide it to separate tracks and videos because i will use those
tables later on the webpage (Videography and Lyrics section).
Basically, 1 album contains n discs and 1 disc is unique to 1 album;
that's a one to many relationship.
1 disc contains n (track or a video)
And 1 (track or video) appears on n disc.
I was able to create the relationship between 'album' and 'disc' but
i'm not sure how to proceed with the track and video table.
I thought of inserting the trackid or the videoid inside a new table;
'multimedia' and create a 'disc_multimedia' table... but it looks
heavy..
I need guidance and expertise.
Thanks in advance
Marco
I'm not sure if you're talking different types of disks (i.e. music cd's
and dvd's) or not, because it seems you're half-way mixing videos and
songs. I am assuming, of course, that a specific disk is not both a
music cd and a dvd.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

That's exact. Some albums can contain a CD (or more) with tracks and a
DVD with videos. I dont' ever remember seeing a CD that contained a
video or a DVD that contained a track for this artist. In fact, i've
done some research on hundreds of albums on amazon.com and most of
them come with a second disc for the dvd video. I did see some
exceptions were a CD contained tracks and the last so call track was a
video... so it is possible.

In my model, i also have a table called 'format' that represents the
type of disc (CD, DVD, LP, EP, SINGLE, etc...). I've created a 1 to 1
relationship with 'disc' and 'format'.

The table 'tracks' contains all the tracks for this artist and the
table 'video' contains videos (not only the videos from this artist
DVDs but videos in general from this artist).

Hope this helps. Thanks again
OK, I'm just used to the old vinyl "albums", where you generally had one
lp per album. Shows you how old I am

In your case I would not have separate tables for CD's and DVD's. I
would have one table with a column indicating which type they are. You
can still search the table for one or the other quite easily.

So I would have:

album - album id, other info
disk - disk id, disk type, album id, other info
track - track id, other info
disk_track (or track_disk, depending on your naming preferences) - disk
id, track id (track number on disk, if you want it)

This allows for a 1:n relationship between album and disk, and a m:n
relationship between disk and track.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #6  
Old   
SM
 
Posts: n/a

Default Re: How to create a 1 to 1 relationship or 1 to many...not sure - 03-09-2010 , 11:07 AM



On Mar 9, 5:46*am, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
Quote:
SM wrote:
On Mar 8, 7:33 pm, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
SM wrote:
Hello,
I'm trying to create a db model for a discography, for one artist.
I have a very basic model that i will improve with time.
Here's a summary of my model. I have approx. 4 databases:
album
disc
* * *track
* * *video
I decide it to separate tracks and videos because i will use those
tables later on the webpage (Videography and Lyrics section).
Basically, 1 album contains n discs and 1 disc is unique to 1 album;
that's a one to many relationship.
1 disc contains n (track or a video)
And 1 (track or video) appears on n disc.
I was able to create the relationship between 'album' and 'disc' but
i'm not sure how to proceed with the track and video table.
I thought of inserting the trackid or the videoid inside a new table;
'multimedia' and create a 'disc_multimedia' table... but it looks
heavy..
I need guidance and expertise.
Thanks in advance
Marco
I'm not sure if you're talking different types of disks (i.e. music cd's
and dvd's) or not, because it seems you're half-way mixing videos and
songs. *I am assuming, of course, that a specific disk is not both a
music cd and a dvd.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

That's exact. Some albums can contain a CD (or more) with tracks and a
DVD *with videos. I dont' ever remember seeing a CD that contained a
video or a DVD that contained a track for this artist. In fact, i've
done some research on hundreds of albums on amazon.com and most of
them come with a second disc for the dvd video. I did see some
exceptions were a CD contained tracks and the last so call track was a
video... so it is possible.

In my model, i also have a table called 'format' that represents the
type of disc (CD, DVD, LP, EP, SINGLE, etc...). I've created a 1 to 1
relationship with 'disc' and 'format'.

The table 'tracks' contains all the tracks for this artist and the
table 'video' contains videos (not only the videos from this artist
DVDs but videos in general from this artist).

Hope this helps. Thanks again

OK, I'm just used to the old vinyl "albums", where you generally had one
lp per album. *Shows you how old I am

In your case I would not have separate tables for CD's and DVD's. *I
would have one table with a column indicating which type they are. *You
can still search the table for one or the other quite easily.

So I would have:

album - album id, other info
disk - disk id, disk type, album id, other info
track - track id, other info
disk_track (or track_disk, depending on your naming preferences) - disk
id, track id (track number on disk, if you want it)

This allows for a 1:n relationship between album and disk, and a m:n
relationship between disk and track.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================
that is the db model i've created before realizing that an 'album'
could contain a 'disc' with videos. If i want to include videos on my
disc, the model breaks up and doesn't work... I just need to tweak the
model to include tracks and videos on discs.... that's where i'm
stuck.

Basically, i have the following:

album: albumid, other info
disc: discid, disctype, albumid, otherinfo
track: trackid, other info
video: videoid, otherinfo

disc_track (since the disc could contain either a 'track' or a
'video', i prefer renaming it to something like 'disc_media'):
discid, ????

How do i include the 'video' table on my model?

Thanks

Reply With Quote
  #7  
Old   
SM
 
Posts: n/a

Default Re: How to create a 1 to 1 relationship or 1 to many...not sure - 03-09-2010 , 11:37 AM



On Mar 9, 11:07*am, SM <servandomont... (AT) gmail (DOT) com> wrote:
Quote:
On Mar 9, 5:46*am, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:



SM wrote:
On Mar 8, 7:33 pm, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
SM wrote:
Hello,
I'm trying to create a db model for a discography, for one artist.
I have a very basic model that i will improve with time.
Here's a summary of my model. I have approx. 4 databases:
album
disc
* * *track
* * *video
I decide it to separate tracks and videos because i will use those
tables later on the webpage (Videography and Lyrics section).
Basically, 1 album contains n discs and 1 disc is unique to 1 album;
that's a one to many relationship.
1 disc contains n (track or a video)
And 1 (track or video) appears on n disc.
I was able to create the relationship between 'album' and 'disc' but
i'm not sure how to proceed with the track and video table.
I thought of inserting the trackid or the videoid inside a new table;
'multimedia' and create a 'disc_multimedia' table... but it looks
heavy..
I need guidance and expertise.
Thanks in advance
Marco
I'm not sure if you're talking different types of disks (i.e. music cd's
and dvd's) or not, because it seems you're half-way mixing videos and
songs. *I am assuming, of course, that a specific disk is not botha
music cd and a dvd.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

That's exact. Some albums can contain a CD (or more) with tracks and a
DVD *with videos. I dont' ever remember seeing a CD that contained a
video or a DVD that contained a track for this artist. In fact, i've
done some research on hundreds of albums on amazon.com and most of
them come with a second disc for the dvd video. I did see some
exceptions were a CD contained tracks and the last so call track was a
video... so it is possible.

In my model, i also have a table called 'format' that represents the
type of disc (CD, DVD, LP, EP, SINGLE, etc...). I've created a 1 to 1
relationship with 'disc' and 'format'.

The table 'tracks' contains all the tracks for this artist and the
table 'video' contains videos (not only the videos from this artist
DVDs but videos in general from this artist).

Hope this helps. Thanks again

OK, I'm just used to the old vinyl "albums", where you generally had one
lp per album. *Shows you how old I am

In your case I would not have separate tables for CD's and DVD's. *I
would have one table with a column indicating which type they are. *You
can still search the table for one or the other quite easily.

So I would have:

album - album id, other info
disk - disk id, disk type, album id, other info
track - track id, other info
disk_track (or track_disk, depending on your naming preferences) - disk
id, track id (track number on disk, if you want it)

This allows for a 1:n relationship between album and disk, and a m:n
relationship between disk and track.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

that is the db model i've created before realizing that an 'album'
could contain a 'disc' with videos. If i want to include videos on my
disc, the model breaks up and doesn't work... I just need to tweak the
model to include tracks and videos on discs.... that's where i'm
stuck.

Basically, i have the following:

album: albumid, other info
disc: discid, disctype, albumid, otherinfo
track: trackid, other info
video: videoid, otherinfo

disc_track (since the disc could contain either a *'track' or a
'video', i prefer renaming it to something like 'disc_media'):
discid, ????

How do i include the 'video' table on my model?

Thanks
the more i think about it, i realize that maybe i should combine the
table 'track' and 'video' into a table 'media'... that way, the model
would work perfectly!... yeap... i think that is the solution....

Reply With Quote
  #8  
Old   
SM
 
Posts: n/a

Default Re: How to create a 1 to 1 relationship or 1 to many...not sure - 03-09-2010 , 11:59 AM



On Mar 9, 11:37*am, SM <servandomont... (AT) gmail (DOT) com> wrote:
Quote:
On Mar 9, 11:07*am, SM <servandomont... (AT) gmail (DOT) com> wrote:



On Mar 9, 5:46*am, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:

SM wrote:
On Mar 8, 7:33 pm, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
SM wrote:
Hello,
I'm trying to create a db model for a discography, for one artist..
I have a very basic model that i will improve with time.
Here's a summary of my model. I have approx. 4 databases:
album
disc
* * *track
* * *video
I decide it to separate tracks and videos because i will use those
tables later on the webpage (Videography and Lyrics section).
Basically, 1 album contains n discs and 1 disc is unique to 1 album;
that's a one to many relationship.
1 disc contains n (track or a video)
And 1 (track or video) appears on n disc.
I was able to create the relationship between 'album' and 'disc' but
i'm not sure how to proceed with the track and video table.
I thought of inserting the trackid or the videoid inside a new table;
'multimedia' and create a 'disc_multimedia' table... but it looks
heavy..
I need guidance and expertise.
Thanks in advance
Marco
I'm not sure if you're talking different types of disks (i.e. music cd's
and dvd's) or not, because it seems you're half-way mixing videos and
songs. *I am assuming, of course, that a specific disk is not both a
music cd and a dvd.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

That's exact. Some albums can contain a CD (or more) with tracks and a
DVD *with videos. I dont' ever remember seeing a CD that contained a
video or a DVD that contained a track for this artist. In fact, i've
done some research on hundreds of albums on amazon.com and most of
them come with a second disc for the dvd video. I did see some
exceptions were a CD contained tracks and the last so call track was a
video... so it is possible.

In my model, i also have a table called 'format' that represents the
type of disc (CD, DVD, LP, EP, SINGLE, etc...). I've created a 1 to1
relationship with 'disc' and 'format'.

The table 'tracks' contains all the tracks for this artist and the
table 'video' contains videos (not only the videos from this artist
DVDs but videos in general from this artist).

Hope this helps. Thanks again

OK, I'm just used to the old vinyl "albums", where you generally had one
lp per album. *Shows you how old I am

In your case I would not have separate tables for CD's and DVD's. *I
would have one table with a column indicating which type they are. *You
can still search the table for one or the other quite easily.

So I would have:

album - album id, other info
disk - disk id, disk type, album id, other info
track - track id, other info
disk_track (or track_disk, depending on your naming preferences) - disk
id, track id (track number on disk, if you want it)

This allows for a 1:n relationship between album and disk, and a m:n
relationship between disk and track.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

that is the db model i've created before realizing that an 'album'
could contain a 'disc' with videos. If i want to include videos on my
disc, the model breaks up and doesn't work... I just need to tweak the
model to include tracks and videos on discs.... that's where i'm
stuck.

Basically, i have the following:

album: albumid, other info
disc: discid, disctype, albumid, otherinfo
track: trackid, other info
video: videoid, otherinfo

disc_track (since the disc could contain either a *'track' or a
'video', i prefer renaming it to something like 'disc_media'):
discid, ????

How do i include the 'video' table on my model?

Thanks

the more i think about it, i realize that maybe i should combine the
table 'track' and 'video' into a table 'media'... that way, the model
would work perfectly!... yeap... i think that is the solution....
ok i believe i got it.
Essentially i would have one master table (multimedia) with subtables
(Tracks and Videos). I will link the two subtables to the master table
through the primary key of the master table.

Then, i'll be able to create the relationship disc_multimedia....

Reply With Quote
  #9  
Old   
SM
 
Posts: n/a

Default Re: How to create a 1 to 1 relationship or 1 to many...not sure - 03-09-2010 , 01:15 PM



On Mar 9, 11:07*am, SM <servandomont... (AT) gmail (DOT) com> wrote:
Quote:
On Mar 9, 5:46*am, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:



SM wrote:
On Mar 8, 7:33 pm, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
SM wrote:
Hello,
I'm trying to create a db model for a discography, for one artist.
I have a very basic model that i will improve with time.
Here's a summary of my model. I have approx. 4 databases:
album
disc
* * *track
* * *video
I decide it to separate tracks and videos because i will use those
tables later on the webpage (Videography and Lyrics section).
Basically, 1 album contains n discs and 1 disc is unique to 1 album;
that's a one to many relationship.
1 disc contains n (track or a video)
And 1 (track or video) appears on n disc.
I was able to create the relationship between 'album' and 'disc' but
i'm not sure how to proceed with the track and video table.
I thought of inserting the trackid or the videoid inside a new table;
'multimedia' and create a 'disc_multimedia' table... but it looks
heavy..
I need guidance and expertise.
Thanks in advance
Marco
I'm not sure if you're talking different types of disks (i.e. music cd's
and dvd's) or not, because it seems you're half-way mixing videos and
songs. *I am assuming, of course, that a specific disk is not botha
music cd and a dvd.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

That's exact. Some albums can contain a CD (or more) with tracks and a
DVD *with videos. I dont' ever remember seeing a CD that contained a
video or a DVD that contained a track for this artist. In fact, i've
done some research on hundreds of albums on amazon.com and most of
them come with a second disc for the dvd video. I did see some
exceptions were a CD contained tracks and the last so call track was a
video... so it is possible.

In my model, i also have a table called 'format' that represents the
type of disc (CD, DVD, LP, EP, SINGLE, etc...). I've created a 1 to 1
relationship with 'disc' and 'format'.

The table 'tracks' contains all the tracks for this artist and the
table 'video' contains videos (not only the videos from this artist
DVDs but videos in general from this artist).

Hope this helps. Thanks again

OK, I'm just used to the old vinyl "albums", where you generally had one
lp per album. *Shows you how old I am

In your case I would not have separate tables for CD's and DVD's. *I
would have one table with a column indicating which type they are. *You
can still search the table for one or the other quite easily.

So I would have:

album - album id, other info
disk - disk id, disk type, album id, other info
track - track id, other info
disk_track (or track_disk, depending on your naming preferences) - disk
id, track id (track number on disk, if you want it)

This allows for a 1:n relationship between album and disk, and a m:n
relationship between disk and track.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

that is the db model i've created before realizing that an 'album'
could contain a 'disc' with videos. If i want to include videos on my
disc, the model breaks up and doesn't work... I just need to tweak the
model to include tracks and videos on discs.... that's where i'm
stuck.

Basically, i have the following:

album: albumid, other info
disc: discid, disctype, albumid, otherinfo
track: trackid, other info
video: videoid, otherinfo

disc_track (since the disc could contain either a *'track' or a
'video', i prefer renaming it to something like 'disc_media'):
discid, ????

How do i include the 'video' table on my model?

Thanks
i guess i have to stop thinking of tracks and more as items. The
moment i see that the cd doesn't contain a track but a video, i am
mentally stuck on the terminology. Basically, 1 disc contains items
and 1 item could be in more then 1 disc. Items could be of type audio
or video... as simple as that... heheh

thanks again for your help
Marco

Reply With Quote
  #10  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: How to create a 1 to 1 relationship or 1 to many...not sure - 03-09-2010 , 04:36 PM



SM wrote:
Quote:
On Mar 9, 5:46 am, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
SM wrote:
On Mar 8, 7:33 pm, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
SM wrote:
Hello,
I'm trying to create a db model for a discography, for one artist.
I have a very basic model that i will improve with time.
Here's a summary of my model. I have approx. 4 databases:
album
disc
track
video
I decide it to separate tracks and videos because i will use those
tables later on the webpage (Videography and Lyrics section).
Basically, 1 album contains n discs and 1 disc is unique to 1 album;
that's a one to many relationship.
1 disc contains n (track or a video)
And 1 (track or video) appears on n disc.
I was able to create the relationship between 'album' and 'disc' but
i'm not sure how to proceed with the track and video table.
I thought of inserting the trackid or the videoid inside a new table;
'multimedia' and create a 'disc_multimedia' table... but it looks
heavy..
I need guidance and expertise.
Thanks in advance
Marco
I'm not sure if you're talking different types of disks (i.e. music cd's
and dvd's) or not, because it seems you're half-way mixing videos and
songs. I am assuming, of course, that a specific disk is not both a
music cd and a dvd.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================
That's exact. Some albums can contain a CD (or more) with tracks and a
DVD with videos. I dont' ever remember seeing a CD that contained a
video or a DVD that contained a track for this artist. In fact, i've
done some research on hundreds of albums on amazon.com and most of
them come with a second disc for the dvd video. I did see some
exceptions were a CD contained tracks and the last so call track was a
video... so it is possible.
In my model, i also have a table called 'format' that represents the
type of disc (CD, DVD, LP, EP, SINGLE, etc...). I've created a 1 to 1
relationship with 'disc' and 'format'.
The table 'tracks' contains all the tracks for this artist and the
table 'video' contains videos (not only the videos from this artist
DVDs but videos in general from this artist).
Hope this helps. Thanks again
OK, I'm just used to the old vinyl "albums", where you generally had one
lp per album. Shows you how old I am

In your case I would not have separate tables for CD's and DVD's. I
would have one table with a column indicating which type they are. You
can still search the table for one or the other quite easily.

So I would have:

album - album id, other info
disk - disk id, disk type, album id, other info
track - track id, other info
disk_track (or track_disk, depending on your naming preferences) - disk
id, track id (track number on disk, if you want it)

This allows for a 1:n relationship between album and disk, and a m:n
relationship between disk and track.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

that is the db model i've created before realizing that an 'album'
could contain a 'disc' with videos. If i want to include videos on my
disc, the model breaks up and doesn't work... I just need to tweak the
model to include tracks and videos on discs.... that's where i'm
stuck.

Basically, i have the following:

album: albumid, other info
disc: discid, disctype, albumid, otherinfo
track: trackid, other info
video: videoid, otherinfo

disc_track (since the disc could contain either a 'track' or a
'video', i prefer renaming it to something like 'disc_media'):
discid, ????

How do i include the 'video' table on my model?

Thanks
A video is also a track. It just might happen to be the only track on
the disk.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.