Just a lil doubt

Thanks in advance

Page 1 of 1

12 Replies - 799 Views - Last Post: 22 June 2010 - 02:09 AM Rate Topic: -----

#1 nradam  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 56
  • Joined: 28-February 10

Just a lil doubt

Posted 19 June 2010 - 10:43 AM

I was in the process of making a website. So now, i have to write some details about the products available in my website. I also have to create user reviews and also user comments (like in youtube etc). So whats a better option here :
1) Store the details, reviews and comments in a database (varchar)
2) tore the details, reviews and comments in a file and then save the file link in a database.
Or do you have some other idea?
Is This A Good Question/Topic? 0
  • +

Replies To: Just a lil doubt

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2890
  • View blog
  • Posts: 10,019
  • Joined: 08-August 08

Re: Just a lil doubt

Posted 19 June 2010 - 10:55 AM

If the number of comments and reviews will be very small (unlikely) then a file will be fine. Otherwise, use a database.
Was This Post Helpful? 0
  • +
  • -

#3 shezzy  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 194
  • Joined: 28-January 07

Re: Just a lil doubt

Posted 19 June 2010 - 10:59 AM

Would def say go with a database for all 3 required items, details, reviews and comments. Start out by figuring out the required fields and tables for products etc for your project. A flat file wouldnt have the relationships in order to string together a product to its review or a comment about a product.
Was This Post Helpful? 0
  • +
  • -

#4 mahcuz  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 143
  • View blog
  • Posts: 213
  • Joined: 03-June 10

Re: Just a lil doubt

Posted 19 June 2010 - 11:27 AM

The first option, every time. Managing data in a flat-file quickly becomes laborious - no point in reinventing the wheel. Of course, if you want to avoid the overhead of a database server, you might look into SQLite.

Mark.
Was This Post Helpful? 0
  • +
  • -

#5 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10385
  • View blog
  • Posts: 38,434
  • Joined: 27-December 08

Re: Just a lil doubt

Posted 19 June 2010 - 12:48 PM

I agree with everyone that a SQL Database will make it much easier to manage. However, if you do go the File route, then I would suggest working with XML. It's a standard format that is fairly easy to parse. In fact, PHP comes with some XML Parsers like SimpleXML and Expat Parser. For more information on PHP and XML, check out the W3Schools page/
Was This Post Helpful? 1
  • +
  • -

#6 nradam  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 56
  • Joined: 28-February 10

Re: Just a lil doubt

Posted 20 June 2010 - 04:23 AM

thanks a lot for the answers people, i appreciate it :D
aitte thats cool.... so sql looks like the way to go. I dont have a really good idea about xml but it looks like something i should start looking at. Someone told me that storing large user reviews and other things in database makes the website slower. Will it be faster if i use xml btw?
Was This Post Helpful? 0
  • +
  • -

#7 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3485
  • View blog
  • Posts: 10,043
  • Joined: 08-June 10

Re: Just a lil doubt

Posted 20 June 2010 - 05:46 AM

View Postnradam, on 20 June 2010 - 11:23 AM, said:

Will it be faster if i use xml btw?

no.

SQL is IMO always faster than an XML file, since you can make the SQL server do the hard work. XML files on the other hand side use an awful lot of memory to load (unless you parse the file line-wise).
Was This Post Helpful? 1
  • +
  • -

#8 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10385
  • View blog
  • Posts: 38,434
  • Joined: 27-December 08

Re: Just a lil doubt

Posted 21 June 2010 - 05:51 PM

XML files are a standard format that are good to use in cases where physical memory is limited, like in mobile devices. However, unless you are storing Files like images, audio, etc., then there shouldn't be a problem storing the reviews in the database. If you are storing files (which it doesn't sound like you are), then just store the path in the database.

For the reviews, you can also limit the number of characters per review when accepting them on the website, as well as in the database when you define the specific string type for the column.
Was This Post Helpful? 1
  • +
  • -

#9 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2890
  • View blog
  • Posts: 10,019
  • Joined: 08-August 08

Re: Just a lil doubt

Posted 21 June 2010 - 06:04 PM

Obligatory warning about SQL injection attacks: Never trust user input.
Was This Post Helpful? 1
  • +
  • -

#10 nradam  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 56
  • Joined: 28-February 10

Re: Just a lil doubt

Posted 21 June 2010 - 09:59 PM

sql injection attacks dammit..... all i know is to use mysql real escape string lol. Is that enough to be called safe?

And btw, i was tryin to upload my website to a host to show you guys. But the problem is, i have a LOT of entries saved in the database in my computer (wamp server). But i did that manually by creating the tables by phpmyadmin and then entering details of cars by using forms. There is a giganitic lot of things to type if i have to do it again for this host. So is there some way that i can get the queries i used to make the tables and inserted values from the wamp phpmyadmin so that i can run the script from the host website and make all the tables and stuff in one go.

PS: Its a free host.
Was This Post Helpful? 0
  • +
  • -

#11 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,880
  • Joined: 10-May 07

Re: Just a lil doubt

Posted 21 June 2010 - 10:07 PM

I would just mysqldump the entire database, upload the output file, & then there ya go. A duplicated database.
Was This Post Helpful? 1
  • +
  • -

#12 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3485
  • View blog
  • Posts: 10,043
  • Joined: 08-June 10

Re: Just a lil doubt

Posted 21 June 2010 - 10:53 PM

View Postnradam, on 22 June 2010 - 04:59 AM, said:

sql injection attacks dammit..... all i know is to use mysql real escape string lol. Is that enough to be called safe?

safe enough for now. although there are edge cases, where you can work around that, too.
Was This Post Helpful? 0
  • +
  • -

#13 nradam  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 56
  • Joined: 28-February 10

Re: Just a lil doubt

Posted 22 June 2010 - 02:09 AM

no 2 pencil....... ur mysqldump kicked ass :D :D Finally my site is uo :) Please check it out and say what do u think about it. Only 50 percent is complete, u can signup, login, buy cars, and add it to cart, logout. Without loggin in you cant access cart, buy or watch your profile. The profile is still to come. Gimme some feedbacks....

http://autogarage.0fees.net/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1