Solved Best Way to store written books in a database?

Discussion in 'Plugin Development' started by mug561, Dec 26, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    mug561

    What did I get myself into ;-;

    So anyways, things lead to more things, and now I need to store written books in a sqlite/mysql database (Well both, but I'd assume my question would be the same for both)

    My Problem isn't getting or storing the author, or title, its the book text. My question is what would be the most practical(even thou the whole concept is not that practical anywho);
    Would it be most efficient to:
    a) Break the book text down into a byte array and store it in a blob column?
    b) Store the whole, long string in a text column
    c) You have no clue what you're talking about. / other ( A little explanation for this would be appreciated ^_^)

    Thank you in advance!

    <sidenote>
    How would one rebuild text from a string to a written book?
    AKA how to separate a string into pages; Should I add a separator character at the end of each page and string.split at character than turn the array into pages? or?
    </sidenote>
     
  2. Offline

    Zombie_Striker

    [​IMG]
     
    mine-care likes this.
  3. Offline

    teej107

    I choose B. Though it really doesn't matter how you do it.
     
    mine-care likes this.
  4. Offline

    mug561

    @Zombie_Striker Global shop plugin. Sell written books too. MySQL database to share between multiple servers seeing the same items for sale. This cannot be achieved with local yml files unless somehow I transfer the book data with sockets/bungee, but even then, players will not be able to search for books by name like i could with SQL: 'SELECT ID FROM INSERTTABLENAMEHERE WHERE name = 'To Kill A MockingBird''; Or something along those lines

    EDIT 1: Herp derp I forgot maps exist. but still. Multiple servers.
     
    Last edited: Dec 26, 2015
  5. Offline

    mythbusterma

    @mug561

    MEDIUMTEXT in MySQL, TEXT in SQLite.

    Any other questions?
     
    mug561 likes this.
  6. Offline

    mug561

    @mythbusterma straight up text would be most efficient/practical?

    If so than thank you :D
    Also:
    Why MEDIUMTEXT? vs just TEXT for mySQL?
     
  7. Offline

    mythbusterma

    @mug561

    SQLite doesn't have a "mediumtext."
     
  8. Offline

    mug561

    @mythbusterma but i mean for mysql. mysql has a 'text' why not just use that? Why use mediumtext?
     
  9. Offline

    mythbusterma

    @mug561

    MEDIUMTEXT is longer and is the standard type for "book" length features, but looking at the actual data table, "TEXT" would be fine as that is more than enough characters for a Minecraft book (around 2^16 characters maximum).

    Although, it doesn't really matter. With BLOBs and text fields, the fields are sized according to the needs of the data being stored, so (almost) no disk space is wasted by choosing the wrong one.

    The only thing that would change is the size of the length field preceding it.
     
Thread Status:
Not open for further replies.

Share This Page