Jump to content

mp3 Shop MYSQL Database


tekcap

Recommended Posts

Hello

 

Im creating a ERD for my Database and am having some problems.

First of all my Database which is for an Mp3 shop has the following Entities so far.

Customer , Administrator , Purchase , Cart , News , Currency , Label , Artist , Song , Genre , Review.

My problem right now is if im keeping referential integrity inbetween my tables and I delete a song then im also deleting any Purchases in my Purchase Table that contain that song. This is a bad idea because I always have to keep track of sales even if I delete a particular song. What is a safe method for creating such a database.

Link to comment
Share on other sites

How would I do that?

You'll have to check the InnoDB refman page... I don't use it, so I don't know, but I'm fairly sure I've seen this somewhere.

 

Im also wondering if I should create a column in user called Logged_in_status or if I should make a whole other table called Logged_in.

That depends how you're going to query it.

Link to comment
Share on other sites

here is a link to my ERD.

http://img185.imageshack.us/my.php?image=erdao9.jpg

Am I missing anything here? Should I be connecting these relationships any more?

Im also wondering if I should put a on off status on tables such as song so if delete a song im not breaking referential integrity to l the purchase items. Is this a good way to approach this? Any links to tutorials that I might find appropriate would be appreciated as well.

Link to comment
Share on other sites

Ok so I will apply an activity field to the neccesary tables.  Thanks !

I was also wondering how should I relate my review table to my song table?

Also wondering if my users are choosing country and province does that mean I need tables for Countries and Provinces?

Link to comment
Share on other sites

Ive never heard the term denormalized table what is that?

I was thinking of also using a php include DEFINE file that lists all the Countries and the currencies associated with it. I also just thought of something. My artist and song relationship is a many to many because a song may have many artists and an artist may have many songs. Should I create a table called artist_songs?

Link to comment
Share on other sites

Yes, artist_songs is a good idea... you need a lookup table for just about any M->N relationship.

 

By denormalized, I simply mean that somewhere you'd have a table where multiple records could share the same field value multiple times (e.g. country for users).  A normalized table would have a separate table for country, and store a country_uid.

Link to comment
Share on other sites

Fenway I have an administrator table which contains a username and password. Should I just get rid of the table and put access levels in the user table? If it will improve speed and make code easier to read ill change it.

Link to comment
Share on other sites

Was looking at my tables today and was wondering if maybe I should remove the E-Mail attribute from Purchase since its already in the User Table. If I do this will I still be able to additionally display the E-mail everytime I query up a list of purchases for viewing? Im also having trouble figuring what would be the optimum data type for my Available status and access level attributes. Basically I only need ON/OFF and 1 for Admin and 0 for User. Also wondering how long I should make my file references.

Link to comment
Share on other sites

If you can get to the user record, you can pull the e-mail from there.  You can use an ENUM datatype for your attribute/status flags, as long as they're not going to change very often.  File references should only include relative pathnames, you can have the full path name in your app.

Link to comment
Share on other sites

I figured the E-Mail will Change in every table that uses it as a foreign key.

Basically the way I see it is if a user changes his E-Mail then it will change all records of his E-Mail in all the tables that use it as a foreign key. Does it only apply to new records added? Or does it do that AND go change all records in the database contaning the Old Email?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.