CodeToad Posted May 29, 2007 Share Posted May 29, 2007 I'm new to dynamic web design and am reading through David Power's book "PHP Solutions" so far so good. The project purpose is that ultimatley I'd like to have a single database that I can add image information (like discriptions, file name, date, etc) and then have my website pull from that. This database will get relativley large in terms of rows, 150+ and I want to be able to select and display the most recent 24 based on the date (integer 20070321 for example). I was thinking of ways to do this in general language, like an if statement to compare dates and assign the greatest 24 to an array, but this seems intensive. Is there a better way to do something like this or am I heading in the right direction? Would a conditional statement comparing each of the 150+ records make the page slow to load for the user? Quote Link to comment https://forums.phpfreaks.com/topic/53449-solved-mysql-database-design-question/ Share on other sites More sharing options...
bubblegum.anarchy Posted May 30, 2007 Share Posted May 30, 2007 Basic table schematic: repository.id repository.date Query: SELECT * FROM repository ORDER BY repository.date DESC LIMIT 24 Quote Link to comment https://forums.phpfreaks.com/topic/53449-solved-mysql-database-design-question/#findComment-264381 Share on other sites More sharing options...
AndyB Posted May 30, 2007 Share Posted May 30, 2007 I would very strongly recommend that you store dates in the ISO format - yyyy-mm-dd as a MySQL date field. It will make any date-related operations so much simpler than if you use an alternate or home-brewed date representation. You can display the date in whatever format you want to, of course. Quote Link to comment https://forums.phpfreaks.com/topic/53449-solved-mysql-database-design-question/#findComment-264393 Share on other sites More sharing options...
CodeToad Posted May 30, 2007 Author Share Posted May 30, 2007 Thank you so much to both of you. You made a newbie's learning process much less painful! Honestly, thanks so much! Quote Link to comment https://forums.phpfreaks.com/topic/53449-solved-mysql-database-design-question/#findComment-265014 Share on other sites More sharing options...
Wildbug Posted May 30, 2007 Share Posted May 30, 2007 150 rows isn't that many. MySQL has been known to handle millions well. What do you mean by "conditional statement?" Or did bg.anarchy solve that? The most useful chapters of the MySQL manual (for learning and reference): 3. Tutorial 11. Data types 13. SQL Syntax 12. Functions (Btw, I like your nick: "CodeToad.") Quote Link to comment https://forums.phpfreaks.com/topic/53449-solved-mysql-database-design-question/#findComment-265038 Share on other sites More sharing options...
CodeToad Posted May 30, 2007 Author Share Posted May 30, 2007 Thanks I'm new to databases but I'm familiar w/ VBa and VB.net, etc type programming. I was thinking I had to call all of the information in the database and then use an if statement to determine the most recent dates, then assign them to an array. Turns out there's a much easier way to do that as bg.anarchy showed me, and I had my dates wrong which andyb showed me I'll check out those tutorials and links, the book I have has been good so far but it's starting to wear a little thin and I am finding myself searching the net for more material, so thanks for the links! Quote Link to comment https://forums.phpfreaks.com/topic/53449-solved-mysql-database-design-question/#findComment-265066 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.