Guest MrLeN Posted November 24, 2016 Share Posted November 24, 2016 I am trying to build a database like this: Username Table (user details) - Username [PRIMARY] - Advertising Code 1 - Advertising Code 2 - Website name - Website URL - Statistics Code I can pretty much make that part. HOWEVER, I have created a form that allows the user to enter YouTube URL with the following form fields: YouTube Video ID table (this is for each video) -YOUTUBE VIDEO ID [PRIMARY] - YouTube Video Title - YouTube Video Description - Comment; ie: the user can add additional text about the video - Advertising Code 1 - Advertising Code 2 - Website name - Website URL I want the video ID to be associated with the Username. HOWEVER, I can't just have all the video ID's in atable, because multiple users might add the save video ID. So, I need something like this: - Username [PRIMARY] - Advertising Code 1 - Advertising Code 2 - Website name - Website URL - Statistics Code ----YOUTUBE VIDEO ID 1 ----YouTube Video Description ----Comment; ie: the user can add additional text about the video ----Advertising Code 1 ----Advertising Code 2 ----Website name ----Website URL ----YOUTUBE VIDEO ID 2 ----YouTube Video Description ----Comment; ie: the user can add additional text about the video ----Advertising Code 1 ----Advertising Code 2 ----Website name ----Website URL How can I accomplish this? I am not very good with databases. I know how to create a database, and I know what tables and rows are. I can create a very simple database, but what I want to do above is beyond my ability to make. I need some guidance on what to do Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted November 25, 2016 Share Posted November 25, 2016 (edited) The current layout doesn't make sense, because you simultaneously want videos to be user-bound (there's a comment field) and not user-bound (you only use the Youtube ID as an identifier). Either you add the user ID to the video table and make the pair(!) of Youtube ID and user ID the primary key. Or you create an extra junction table where you assign user IDs to video IDs and store user-specific data like the comment. Edited November 25, 2016 by Jacques1 Quote Link to comment Share on other sites More sharing options...
benanamen Posted November 25, 2016 Share Posted November 25, 2016 For starters, when you are naming columns like some_column1, some_column2 etc, you are already heading the wrong direction. Look up and learn Database Normalization. Quote Link to comment Share on other sites More sharing options...
Guest MrLeN Posted November 25, 2016 Share Posted November 25, 2016 For starters, when you are naming columns like some_column1, some_column2 etc, you are already heading the wrong direction. Look up and learn Database Normalization. Is that because underscores are used as table prefixes and if I put them in column names, I could cause a big headache? Should I take the underscores out? Quote Link to comment Share on other sites More sharing options...
Guest MrLeN Posted November 25, 2016 Share Posted November 25, 2016 I've got US $100 if someone will help me for 4 hours to get this database made.I'm getting a sore brain. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted November 25, 2016 Share Posted November 25, 2016 How about simply reading the replies? Quote Link to comment Share on other sites More sharing options...
Guest MrLeN Posted November 25, 2016 Share Posted November 25, 2016 I read them but I do not understand them properly. I am not a very good programmer. I tried to make a database, but it's too complicated. I am ok with front end stuff and can write php, but databases for me.. it really does my head in. Quote Link to comment Share on other sites More sharing options...
Guest MrLeN Posted November 25, 2016 Share Posted November 25, 2016 And I really want to get my script working today, so I can get back to what I am good at -- promotion.I am the worst programmer in the southern hemisphere.I am not joking. Quote Link to comment Share on other sites More sharing options...
Guest MrLeN Posted November 25, 2016 Share Posted November 25, 2016 http://www.utteraccess.com/wiki/index.php/Junction_Tables_(Many-to-Many_Relationships) My problem is (in the classes example above).. that two different users might add the same video ID. So I can't keep all video ID's in the same table, and bridging them with a junction table. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted November 25, 2016 Share Posted November 25, 2016 Being able to assign the same video to multiple users (and vice versa) is the whole point of a junction table. Quote Link to comment Share on other sites More sharing options...
Barand Posted November 25, 2016 Share Posted November 25, 2016 Your tables would be something like this. Although I am unsure about the advertising codes, which crop up everywhere in your model. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.