Jump to content

A program with a Student database

BrownZeus

Hey guys,

 

so I'm writing a program for a driving school and I was wondering if anyone has an idea of how I can account for Students with the same name.

 

As I have it set up now, each student has their record in their own csv file. FOr example student John Doe has his information in JohnDoe.csv, which is saved to the folder "Customers" on the C drive.

The GUI displays the file names of the folder "Customers". There is no logical way of accounting for students with the same name unless we add a number to their file name, which would result  in that number showing in the dtabase. That would result in the end user having to memorize or open every John Doe n (where n is a number) to view or edit a student file for each student of the same name.

 

To view, edit or add to a student's record the program simply opens a gui which opens the file in the background, get the information, and if anything is being added or edited, appends the information and then closes the file in the background once the window is closed or "save" is clicked.

 

I was thinking alternatively naming the csv files with their license numbers instead, because every driver has a unique license number, period. But here's my issue with that:

 

The program would have to open every student file and get the student names out of them. Eventually the Big Oh factor (Time Complexity for those who don't have a formal understanding of Data Structures) of that is going to increase to a point where it just isn't usable because the Big Oh at program launch is growing at  a rate of n+1 with every new student that gets added.

 

On top of that the RAM space needed at launch might also grow (I haven't tried this idea out yet so I don't know quite yet). I have yet to figure out if the ram is really negligible for this project.

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, edward30 said:

Is this a serious post or a troll? Why aren't you using SQL or some such with a proper engine? If you need CSV files available, why not just generated them as needed?

 

Is this a school assignment?

For starters, not only am I a pretty novice programmer, I'm a pretty mediocre one at that. This project is for a family friend who asked me to do it on my free time cause it wasn't anything urgently needed.

 

Secondly, I know only Java, and though I know SQL isn't difficult to deal with and too hard to inject into a Java program, I don't fully understand SQL and therefore I don't feel comfortable adding it into my program.

 

Thirdly, the CSV files are generated to store the Students' info. So they are being generated as needed, I'm concerned about displaying the Student name/records in the gui to be selected for editing or adding on to after they have been added to the program. I'm not stupid.

Link to comment
Share on other sites

Link to post
Share on other sites

Even though @edward30 wasn't very tactful, his point is a good one. You really should use something like an SQL database for this task. There's going to be huge overhead if you have to do everything through the OS file system.

 

If you really insist on doing what you're doing, you could call the csv files something like "<randomString>-<name>", and the chop off everything before the "-" before displaying the name. 

 

But seriously, use a proper database :)

Link to comment
Share on other sites

Link to post
Share on other sites

Whether you use a database, csv files, or some other option, you need a way to uniquely identify a student. Given your CSV system, that unique identifier is what you'll need to use for the filename (or at least be part of the filename).

 

If the school gives every student a unique ID number, that's one option for a unique identifier.
If they give every student a unique email address, that could be another option.
If they give every student a school login, then the username/login id should be unique and that could be another option.

If they require the student to register, then they can have the student provide a valid identifier (ex: their own email address, social security number, login id, etc)

etc

 

If there's no unique identifier given to students by the school, and you don't get them to provide one, then I suppose you'll have to use a combination of non-unique identifiers that, when combined, give you a unique identifier. You'd still have to enforce that this combination of identifiers is unique though.

Link to comment
Share on other sites

Link to post
Share on other sites

If it's an application that you are doing for real (not like a project for yourself) that would be used by some company then please for the love of Lord Gaben use a proper database. Learning SQL is nothing compared to dealing with dynamically generated CSV files and you can always use SQLite which is essentially a file that you just store somewhere so you can "take it with you". You will learn something this way and create an app what will be somehow useful and possible to maintain. 

Try, fail, learn, repeat...

Link to comment
Share on other sites

Link to post
Share on other sites

If this is a school, then you can add a semester field, indicating which time period the student is being instructed in.

You can also add a field for what date the student was added.

You can also add phone number and address, since more than likely you'll need to have those fields anyway.

 

You will however want to have an id field as well uniquely identifying everyone in your database no matter what.

 

I will say this, I do encourage projects like this.  I've been programming for 10 years, and I still get curious programming fields outside what I do, and love coming up with pet projects like this that give me a chance to understand how this stuff works behind the scenes.  I love it and actively encourage other programmers as well......

 

But.....

 

There is a difference between learning, and writing production code.  This is not a knock against you at all, but you really don't know what you're walking into.  This is a field that has taken tens of thousands of programmers years of trial and error, and some of the brightest minds of the last fifty years to develop effective and efficient ways to organize and use data like this.   Don't get me wrong, you can get a basic program doing what you specified in your original post.  But to really add any additional features, even basics functions like sorting, searching, or just organizing the data in a way that you can present it in your UI, requires a very robust database engine, and you will find that not having that solid engine at the core of your program is going to make the design, and adding additional features a nightmare. 

 

You say you don't know much about SQL.  Great!  You have the perfect opportunity here.  Having a project like this, especially one where there isn't really any pressure on you, is a great way to learn.  You're not just screwing around, writing random code to see what happens, you have a clear idea of what you want, which let's you judge the program's output.  

And even better, is that if you get experience with a program like this at a higher level, understand what you want it to do, it will make it easier to design your own database engine, because you won't be starting from scratch.  You won't just have an idea to implement, you'll have experience using a working one, both it's flaws and strengths.  You honest to God have no idea how valuable that experience is when trying to design a complicated system like this.  

 

I have mad respect for you wanting to tackle a project like this, and I hope you continue to work on it, but if you are going to develop this program to be used by someone else, you really should go about it this way.  You may not be a professional, but hey, fake it till you make it.

Link to comment
Share on other sites

Link to post
Share on other sites

Thanks for all the input, from everyone.

 

SQL pretty much is the only idea given so I'll put my time into that.

 

@edward30 

None taken, and thank you for the API suggestion I'll look into it.

 

@JacobFW 

Thanks for the support. Even though there is no pressure on me for this project, it'll still technically be my very first , I guess real, development project. Its great that I don't have too much pressure on me, but the project is for the business of a family friend, and therefore I do want to deliver a polished project done properly, its why I've taken to the forums for suggestions and help. The whole reason why I've even been given this project is cause the driving school I'm doing this for already has a Custom made program to do what my program will do, minus a few additions (Like the ability to simply scan the barcode of a License or Permit and have it create the new student entry automatically), but not only was it made in the early 90's, the man who made it for them didn't give them the source code and unfortunately, he's passed away. So I'm  starting from scratch, which isn't too much of a big deal, I've put in a total of about 6hours straight of actual work on the project and the backend is more or less done. Now I'm down to ironing out kinks, like this dilemma of accounting for students of the same name, and then I have to move on to designing the front end, whcih will be a pain of its own given Netbeans GUI form makes it a task to do simple things in some cases. 

When I deliver the program, I'm also going to give them the source code so later down the line if I'm ever unable to maintain the program for them, they can pass it along to another programmer willing to take on the job. And so for Simplicity's sake I've been trying to keep it down to basics as much as possible. The API Edward suggested will be he second API I'll be adding on to the project, the other API being a simpler Serial Input API.

 

@madknight3

I'm going to make it a pairing of Name and License number to be displayed, and most likely the date the entry was last modified, cause I imagine they won't always have more than one person with the same name a time.

 

 

Again thank you ALL for your suggestions, and more importantly, your time. 

 

Time to get to work!

Link to comment
Share on other sites

Link to post
Share on other sites

On 11/07/2017 at 6:37 PM, edward30 said:

Is this a school assignment?

On 11/07/2017 at 6:41 PM, BrownZeus said:

This project is for a family friend who asked me to do it...

So it's someone else's school assignment then.

On 11/07/2017 at 6:41 PM, BrownZeus said:

CSV files are generated to store the Students' info

It is absolutely insane to be trying to hand roll your own DBMS in such as way...

On 11/07/2017 at 6:41 PM, BrownZeus said:

I don't fully understand SQL and therefore I don't feel comfortable adding it into my program.

This is simply not the attitude to take... You have just encountered the right tool for the job (and a pretty simple tool at that) but instead of learning it you've thrown up your hands exclaiming that it's too hard for you to even approach so instead you'll just struggle on trying to bang a square peg into a round hole... Just wow O.o

On 11/07/2017 at 6:41 PM, BrownZeus said:

...not only am I a pretty novice programmer, I'm a pretty mediocre one at that.

You should have a look at SQLite, there's also many very simple tutorials on how to interface with it from Java such as this one. It's about as simple an ecosystem as you can get (beyond maybe local NoSQL) since this removes the design patterns/abstraction layers as well as the server from the equation - it's at least a starting point for learning.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, edward30 said:

for these circumstances the right choice is most likely (depending on requirements) a spreadsheet, not custom software ;).

really? You understand that reading a file line by line to find the data you want is massivly slower that an SQL type query? also using a spread sheet to manage data doesn't scale well.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

35 minutes ago, vorticalbox said:

really? You understand that reading a file line by line to find the data you want is massivly slower that an SQL type query? also using a spread sheet to manage data doesn't scale well.

Moreover given the OPs attitude, perhaps it's for the good of all that they stay well away from any code :D

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

If you read up on EJBs and JPA you won't have to learn a lot of SQL, you'll just have to understand how the basic concepts of it works. A lot of companies, especially more time-pressed companies with a need for a quick way to store and retrieve objects in a database will resort to such frameworks that allow them to abstract away all the messy database aspects such that you can focus on the business logic. This seems like a great use case for it since performance overhead isn't a huge deal.

 

With that said, it seems to me that you're not ready yet for such projects if this is your plan for a system that's actually going to be used by someone. Instead of starting out with poorly planned projects that does stuff the wrong way, I suggest that you rather spend your time learning the skills that you'll eventually have to learn in order to create robust, useful and scalable applications instead of improvising with poor solutions. In this case, you'd benefit from being able to properly plan your application. Drawing UML diagrams and domain models are good ways to get a general idea of the archiecture and scale of the application (and trust me, if you're starting without a somewhat decent plan, you will pay for it later). Then you'd also see the benefit of a database storage solution, both for the sake of complexity, scalability and portability (which is where SQL, and maybe also JPA&EJBs will help you out). I'd recommend getting books on the fundamentals of database systems and software structures. Just that will get you a long way if developing a working application for someone to use is your main goal. 

Link to comment
Share on other sites

Link to post
Share on other sites

On 7/11/2017 at 0:03 PM, BrownZeus said:

Hey guys,

 

so I'm writing a program for a driving school and I was wondering if anyone has an idea of how I can account for Students with the same name.

Well, using an actual database is definitely the way to go here, but since you can't do that just yet, may I suggest the simple name and ID number? Each student gets a name, and is also assigned a number based on when they were entered into the system. The two are concatenated, and you end up with "John Doe 0" and "John Doe 1".

Or, perhaps using some other identifier that's useful but is never going to be identical will be useful. Like, name and address. 

ENCRYPTION IS NOT A CRIME

Link to comment
Share on other sites

Link to post
Share on other sites

12 hours ago, edward30 said:

If it is a small business, especially owner operator, the number of clients will not be large. Further, a loaded spreadsheet will be in memory, meaning the find functionality will find the student extremely quickly.

How short sighted, just because it's a small business now doesn't mean its always going to be. One should always code in such away that it can scale up and down with little to no problems. 

 

what happens of students talk to people and they get an a flood of students? More data than can he held in RAM? You would then have to re-code to not load it all in memory and reading line by line so slow so you'll have use a database so why not just do it now?

 

what if some poorly coded app uses up lots of ram and corrupts the data? with a database you can have it so all actions are attempted and only written when successful and rolled back if there is an issue.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

11 hours ago, edward30 said:

One thing you might not understand, is that as a programmer it isn't necessarily your job to write new software. It is your job to solve problems. If the problem can be solved by the use of easily available, easily understandable off the shelf software, then that's what you advise.

in this situation you're very wrong. Adding SQLlite to java in OPs is by far the the easiest way to solve the problem more over is actually quite trivial it add a database. 

 

http://www.tutorialspoint.com/sqlite/sqlite_java.htm

 

and no as a programmer you are meant to create a solution that will handle a clients needs and deal with increased demand without any changes or as little as possible.  

 

like when building a website one wouldn't build a website that can only handle 10 users and then need changing in two months time because they decided they want to add 1 more user. 

 

Making decisions that will allow an application to scale is the sign of a good programmer not a bad one. 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

I didn't really want to comment on your post, but I feel like I have to.

 

15 hours ago, edward30 said:

One thing you might not understand, is that as a programmer it isn't necessarily your job to write new software. It is your job to solve problems.

It's correct that we're aiming to solve problems, but it's not as simple as "make something that works". A solution should always satisfy the basic principles of software development if you're developing a tool for someone else to use. Is the application robust? Is it secure? Is it difficult to maintain? Does it scale well? It's your fault if it breaks or is otherwise unstable, or even worse, compromises confidential information. By just following good practises and planning well, these can mostly be dealt with, and you're not encouraging that by denying that the solution presented in this thread is terrible.

 

If you ever go to college for software development classes or engineering, this is what they'll teach you from the very start. You'll learn how important it is to not just solve problems in a crappy manner like the OP has done, but you'll learn how important it is to develop good habits and knowlegde of the best and most common practises when writing software that has the potential to cause problems if it fails.

 

15 hours ago, edward30 said:

Creating scalable infrastructure is commendable, but only if there is the capacity for growth -- otherwise you're merely adding code that needs to be maintained and often bloated unnecessary practices.

It's usually more expensive and troublesome to expand later if the application architecture either doesn't scale well or straight-out doesn't work at a certain scale. The ultimate answer is to write something solid that scales well in the first place. Creating something that doesn't scale well in the frist place is often the source for hard-to-maintain and crappy code. If your plan is solid and your programming skills are on-point, this usually isn't an issue, and if it somehow turns out to be an issue, you should go back to practising instead of implementing poor solutions.

 

In this specific case you're even more wrong, because a proper storage solution would drastically increase reliability, which would be very important if someone has to rely on your application in order to retrieve data.

 

15 hours ago, edward30 said:

This understanding is one of the things that separates the respected professional from the low level code monkey.

No. This understanding is one that will leave you unemployed.

 

15 hours ago, edward30 said:

There is no reason to believe that the OPs friend would want to expand to take more clients than he can manage at the moment, or that he would be able to scale his business quickly enough to take advantage of a sudden surge in demand anyway (and that would be risky), even without tech limitations. Clearly you've never been in business.

We don't know that. Your're making assumptions, and wrong assumptions can be expensive and troublesome. And I say it again, just coming up with a better solutrion would handle this anyways.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, edward30 said:

SQLite is serverless, so would only function on one machine anyway...

even still is it much much faster than files/xml/json which have to be read line by line. if you're changing data for example, the program would have to search line by line until it gets the one it needs.

 

you don't have that overhead with a database thus is better all around, even of as you say it only on one machine.

3 hours ago, edward30 said:

Sorry to be harsh before, but you were being quite antagonistic.

nothing harsh, didn't intend to be antagonistic. Such is the way with written text :) just a clash of opinions and something to think about.

 

in uni i did a group project where we have to make a web service where users could store playlists. All other groups have thousands of lines of code as they used xml files to store their data.

 

we went for a mysql database that returned queues as xml, much faster and a lot less code. Our server code was less than 500 lines, other groups were messed we did it with so little code lol

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Aww you seem to have reconciled your differences ^_^ I was all like:

PcoPQXL.gif

xD

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

After reading over all the suggestions and input so far, I see points from every side that have merit. Alas even though the points given have merit let us take a closer look at the Original question. 

 

He is wanting to write a general database driven project, identifying the project like he did is admirable. lets take a look:

 

His Program is listing all the cvs files names in a folder - the issue he is running up against is duplicate names - "On the surface this could be handled the same way as duplicate file names would be in a standard file system, basically appending a unique identifier to make duplicate names unique. - This knowledge can be applied to other more appropriate projects but still not the solution he needs."

 

Now for the sake of learning lets follow his logic (and the use of the wrong tool for the job), another solution he could apply would be as follows:
"Create a master cvs file that contains the following information (first, last, middle initial, Unique key(this can be generated)), now he simply name all the other cvs files to match the "Unique Key" that is contained in the Master File. Allowing the frontend to load the master file on startup giving the user the list of names to choose from, then use the unique key to open the actual file containing the personal information"  - Again this is not a recommended solution either , but wait with this solution you just made a rudimentary database so that should lead us to the proper solution we need a database.

 

Like the others have said for this level of project - Single computer, with the software just being installed on a single machine then SQLite would be a good fit, another in the use case but a bit more cumbersome is Access, doesn't work to bad if they have office installed.mySQL and SQL would be the best solutions based on what level of scalability you want your program to have. 

 

Remember everyone starts somewhere, so it is always great to take the time to teach people how to get to the correct answer then just giving them the answer and hoping they fundamentally understand how to come up with the correct solution. 

Current Build - please no laughing!  Always looking for a comfortable replacement to my old Merc stealth and Steelseries Glass mousepad. 

  • CPU:                I7 4770-K 3.5GHz Running @ 3.9GHz
  • Motherboard: Asus Sabertooth Z87 V1.0
  • RAM:               HyperX Fury (2 x 8GB) DDR 3 1866
  • GPU:                Sapphire R9 270X 4GB
  • Case:               Cooler Master HAF XB EVO
  • Storage:          1 x Samsung 840 EVO 250GB, 1 x Samsung 850 EVO 250GB
  • PSU:                SILVERSTONE ZM1200M 1200W ATX
  • Display(s):      1 x Phillips BDL4645E 47" , 2 X Hanns-G Hi221 22"
  • Cooling:          Corsair H100i 240mm AiO Water Cooler
  • Keyboard:       Steelseries APEX (Raw)  + G13 Keypad 
  • Mouse:            Logitech Proteus Core G502
  • Sound:            Sony 7.1 Home Theater System
  • OS:                  Windows 10 Pro x64

System Built in May of 2014 - Silverstone PSU  and Hanns-G Monitors are from my Feb. 2009 Build.

 

Favorite Quotes:

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein

“Now I am become death, the destroyer of worlds" - Thought by J. Robert Oppenheimer 

Link to comment
Share on other sites

Link to post
Share on other sites

12 hours ago, edward30 said:

Want to weigh in?

Not particularly but maybe just another pony meme:

vfqiiCG.png

This is probably the OP right now xD

32 minutes ago, Ashoroth said:

Remember everyone starts somewhere, so it is always great to take the time to teach people how to get to the correct answer then just giving them the answer and hoping they fundamentally understand how to come up with the correct solution. 

I think that you may have missed the point; the OP chose to simply disregard advice and continue on down an inappropriate path, displaying an unwillingness to learn. Honestly, it's probably doubtful that they are even monitoring this thread anymore xD

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

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

×