Sign in to follow this  
jalexbrown

Need Some Ideas

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this