Jump to content
  • Advertisement
Sign in to follow this  
jalexbrown

Need Some Ideas

This topic is 3791 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm in my third quarter of Java Programming, and for the final I have to make a program of some sort that incorporates a database. We can use a Microsoft Access database, or, for extra credit, we can use a MySQL database. I'd really like the extra credit, so I'm leaning towards the MySQL side. I need some suggestions as to what program I could make. Also, if you could give me a very basic code for incorporating a MySQL database, that would be highly beneficial. Thanks for any help that can be offered, Jalexbrown

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by jalexbrown
I'm in my third quarter of Java Programming, and for the final I have to make a program of some sort that incorporates a database. We can use a Microsoft Access database, or, for extra credit, we can use a MySQL database. I'd really like the extra credit, so I'm leaning towards the MySQL side. I need some suggestions as to what program I could make. Also, if you could give me a very basic code for incorporating a MySQL database, that would be highly beneficial.

Thanks for any help that can be offered,
Jalexbrown


Quote:

Original post by Valderman
I think it sounds just awesome to be a voter in the U.S. It always seems that you're choosing between Hitler, Stalin and Jack the Ripper.


Make voting system [smile] where you store voting results in several regions.
Region A:
Political Party 1: Voted for 1284
Political Party 2: Voted for 563
Political Party 3: Voted for 34563
Political Party 4: Voted for 34763
Political Party 5: Voted for 5435
Valid votes: 438734 Not Valid: 23
Region B:
....
etc.
And on the end summarized result for votes.
You will need to create several databases for this


Database: Political_party
Field 1 (unique id) , Field 2 (Party_name)
example: 1 | Black , 2 | Orange, 3 | Purple


Database: Region
Field 1 (unique id) , Field 2 (Region_name)
example: 1 | Oklahoma, 2 | Texas, 3 | California


Database: Vote
Field 1 (unique id) , Field 2(Region_id), Field 3(Voted_for)
example: 1, 1, 1 (meaning vote is for Black party in Oklahoma), 2, 3, 2 (meaning vote is for Purple party in California) etc



And summarized results table:

Region
Oklahoma: Black 23% Orange 65% Purple(12%)
Texas: Black 13% Orange 22% Purple(65%)
etc



You can get results with simple queries in MYSQL
"SELECT * FROM Vote WHERE Region_name='Oklahoma' AND Political_party='Orange'"


Share this post


Link to post
Share on other sites
Quote:

Also, if you could give me a very basic code for incorporating a MySQL database, that would be highly beneficial.



I think a good way to query the database would be to create a query structure like:

struct Query
{
std::string Select;
std::string From;
std::string Where;
etc...
};

and then pass this and an argument to the database eg.

Query Q;
Q.Select = "...";
Q.From = "...";
Q.Where = NULL;

Output Out;

DataBase.Query(&Q, &Out);

the output structure would contain the result of the query.

I've never worked with sql databases before so there might be a lot of things I haven't considered in this code.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!