Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2011
    Posts
    3

    Question Unanswered: Is mySQL the right software to use

    Hi all,

    I'm writing a program using Java and database software for a project. I am to write a program that looks at all the models of Lego that can be made from a certain set of blocks. That means if I have a set of blocks in a pack of Lego:
    (BlockType - Amount):
    block1 - 100
    block2 - 120
    block3 - 80
    block4 - 60
    ...
    blockn - x


    And lots of recipes for different models eg:

    Recipe1
    block1 - 20
    block2 - 20
    block3 - 0
    block4 - 10


    Recipe2
    block1 - 40
    block2 - 10
    block3 - 20
    block4 - 0


    Then my program should be able to sort through the data and see that from my set of Lego blocks I can make either 3*Recipe1 and 1*Recipe2 or 1*Recipe1 and 2*Recipe2.

    There will be a database containing all the recipes for different models and there will be up to about 50 block types. I know this looks a bit daft but this is analogous to my final project.

    Before I go wasting my time getting to grips with mySQL, is this something I can use with Java for my project? Any information on whether this is the right way forward, or sources of information for newbs on the subject is greatly appreciated. Thanks in advance.

    Rich

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Not sure why you need Java here as you can do what you want with a single MySQL statement. Incidentally there is no need to store the types of blocks that are not needed ie block3 in recipe 1.

    Dare I ask what your final project is?

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by mike_bike_kite View Post
    ...with a single MySQL statement.
    i doubt that very much

    but as to the original question, sure, mysql will support this project easily, and as far as i know, using java is just as feasible as using any other application language that has a mysql interface
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Apr 2011
    Posts
    3
    Java is required to make the app user friendly and allow any novice to be able to run the program, plug in something into a simple window and get exactly what they want out of it.

    We've not been told what our final project will be yet. All I know so far is that if we get this working properly then we will have covered all the basics needed for the final project.

    Doing some searching I found that there is functionality for Java to work with mySQL using MySQL Connector/JDBC Java connector.

    I suppose I the real question I should have asked is are Java and mySQL compatible, or are they a pain in the backside to use?

    Thanks,

    Rich

  5. #5
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Quote Originally Posted by r937 View Post
    i doubt that very much
    I just sent you a single SQL statement that hopefully proves it can be done
    It's only a dozen lines long, and while it's not perfect, it should be adequate for this.
    Can't really post it here otherwise the poor guy won't have that much to do.

    Mike

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    mike, your solution did not come up with 3*Recipe1 and 1*Recipe2

    i still don't think you can do it in one query

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Ah no - but it does show how many of each recipe can be made with the blocks you have which is what I thought he was asking! That will teach me to read the spec too quickly I was tempted to having another go but I suspect I'd be pushing the boundaries of what constitutes a single statement and I also suspect I'd be doomed to failure.

Tags for this Thread

Posting Permissions

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