SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    May 2004
    Location
    houston
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Which way to store data?

    I am going to be working on a "knowledge base" type site (internal KB for a small group of people really). It will just be alot of articles, and I am trying to think of how exactly I want this to work.. Mostly I am stuck deciding exactly how I want the articles stored.

    First I have realized I dont want to store the entire article in a database, thats too much information being pulled around, and i figure its easier to just have highlights, keywords, and other various information stored in a database, and the articles themselves as actual files.. XML, HTML, TXT is what I am trying to figure out..

    HTML would be rather simple, someone can easily create an article, and have full control over the way it looks (possibly too much control?), and it would be fine, I would just include_once("filename.html")... but possibly too much control.. thats the bad thing..

    Now, XML, possibly too little control, but I could easily put in more tags on request. It would be a bit more secure..

    TXT files I suppose go the same way with HTML files..


    I happen to think that using XML files would probably be the best way to go.. I was just wondering if anyone else had any thought on the idea, and could give me some tips. Thanks everyone!!

  2. #2
    SitePoint Guru gavwvin's Avatar
    Join Date
    Nov 2004
    Location
    Cornwall, UK
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could put them in separate files, but then you have to worry about 2 datasources (eg what if its there in the database and no file etc) and keeping them together. There's no real reason not to keep the article text in the database itself. Then the user could search the actual text.
    With regard to allowing control of layout, you could use what this and most other forums use eg [ b ] bold text [ / b ] or [ url ] http://mysite.com [/ url ] and use a short function that replaces each tag with its real html equivalent after you pull it out of the database. You could then add as many tags as you wish to allow.

  3. #3
    PHP Brainiac dg_den_golotyuk's Avatar
    Join Date
    Jul 2006
    Location
    Kiev, Ukraine
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can also store whole files in DataBase in BINARY fields but then you must cnsider lower speed then static files
    DG [Den Golotyuk], Lead Developer
    Chestnut Software
    Avoid web outsourcing scams!
    Click here
    for a free downloadable report

  4. #4
    SitePoint Enthusiast Pablasso's Avatar
    Join Date
    Jun 2003
    Location
    Guadalajara, Mexico
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should take in account that some functions are a lot easier on databases rather than on XML files, like searching

    i wouldn't use XML for that kind of applications unless i need syndication

  5. #5
    is_empty(2); foofoonet's Avatar
    Join Date
    Mar 2006
    Posts
    1,000
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jeraych
    I am going to be working on a "knowledge base" type site (internal KB for a small group of people really). It will just be alot of articles, and I am trying to think of how exactly I want this to work.. Mostly I am stuck deciding exactly how I want the articles stored.
    If its only small, I would go for the dbase option too, you could then use a cacheing mechanism to write a permanent file out.. only overwrite it if the database row is ever amended.

    Quote Originally Posted by Jeraych
    First I have realized I dont want to store the entire article in a database, thats too much information being pulled around, and i figure its easier to just have highlights, keywords, and other various information stored in a database, and the articles themselves as actual files.. XML, HTML, TXT is what I am trying to figure out..
    But then you lose the ability to have it searchable, with a cache, and the text in the dbase then you can search the original text and link to the permanent cached file. Use a mysql fulltext index.

    Quote Originally Posted by Jeraych
    HTML would be rather simple, someone can easily create an article, and have full control over the way it looks (possibly too much control?), and it would be fine, I would just include_once("filename.html")... but possibly too much control.. thats the bad thing..
    This is where you piqued my interest, I am grappling with ideas for an "static CMS" containing pages.
    Now the only real difference between my "pages" and your "articles" is likely to be that pages contain anchor points and a menu at the top of the page... ie how to generate valid links like this:
    Code:
    <li><a href="#chapter1">Introduction</a></li>
    and 
    <h3 id="chapter1">Introduction</h3>
    Quote Originally Posted by Jeraych
    Now, XML, possibly too little control, but I could easily put in more tags on request. It would be a bit more secure..
    Quite, you dont want users adding any old thing (for you a wysiwyg textarea editor like TinyMCE might just do)

    Quote Originally Posted by Jeraych
    TXT files I suppose go the same way with HTML files..
    Instead of plain old text, look at maybe allowing them to write a text file in the ini format? Then www.php.net/parse_ini_file (once, on update) then cache it.

    Quote Originally Posted by Jeraych
    I happen to think that using XML files would probably be the best way to go.. I was just wondering if anyone else had any thought on the idea, and could give me some tips. Thanks everyone!!
    In my case I agree, hence I am grappling with the idea, havent really spent too long on it, but your post reincarnated it again!
    Code:
    <document>
    <para chap="1" name="Introduction">
    The text of paragraph one would go in here and the users can do what they like as long as it only contains only tags from a white list, then gets passed through htmlTidy for validity.
    <para>
    
    ... // and so on ...
    
    </document>
    Then that xml could be passed to XSLT (once, on update) to write a cached file as previously described. Not bothered about search, we use the SOAP and the Google search API. (less than 1000 searches a day, see?)

    Are you using PHP5 - with simpleXML ?

    I might have a go at this ...
    Upgrading to Mysql 5? Auto-increment fields now strict
    use NULL
    Or zero or leave the field name out completely.

  6. #6
    SitePoint Zealot
    Join Date
    May 2004
    Location
    houston
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually I am using PHP/4.3.9 ... I don't really have a place to work with PHP5, otherwise I'd possibly be using SimpleXML.. SPeaking of which, if anyone has a place I can host (just testing stuff really), I would like to be able to play around with PHP5 and such... (I already have a book too!!), I can pay if need be lol.

    I love you all!

  7. #7
    is_empty(2); foofoonet's Avatar
    Join Date
    Mar 2006
    Posts
    1,000
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should install php5 on a local machine - dig out an old PC and install it.

    PHP5 (.2) is the way to go.



    If you really want to get the drift on upgrading from 4 to 5 then I can recommend Trachtenbergs "Upgrading to PHP5" - small book, well written and a real eye opener - helps you pull yourself up the ladder too...
    Upgrading to Mysql 5? Auto-increment fields now strict
    use NULL
    Or zero or leave the field name out completely.

  8. #8
    SitePoint Zealot
    Join Date
    May 2004
    Location
    houston
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nah there isn't really an old machine around my house that I can install it on, but I normally only program while at work.. -shrugs- Just me I guess. I will try to find a cheap hosting package around that allows for PHP5

    oooh and thank you very very much for introducing the parse_ini_file() function, its awesome. :P

    SO you think simpleXML would be a good idea huh?

  9. #9
    is_empty(2); foofoonet's Avatar
    Join Date
    Mar 2006
    Posts
    1,000
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SimpleXML just looks, well, simple to use.

    These js dom tricks give me a few ideas too:
    http://www.quirksmode.org/dom/cms.html
    http://www.quirksmode.org/dom/domform.html
    Upgrading to Mysql 5? Auto-increment fields now strict
    use NULL
    Or zero or leave the field name out completely.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •