r/learnprogramming • • 17d ago

Pseudocode and project planning help Working on my first project

The professor has assigned us a task that asks us to develop a basic information system for a hospital(departments, staff, patients, network-connected computers). Its for a first semester course so i am guessing it's pretty basic. It wants me to make a database and connect my program to it. I honestly don't know how to start on the C code. So far, my teacher has essentially been telling us what to do because she is teaching us the syntax and basics(we've only studied C in practical labs and not in any theoretical class). I don't want to get reliant on AI to think and i don't want to get stuck in tutorial hell like people warn about. I don't know how to start without these two things. We haven't even been taught how to connect a database to a program but the deadline is next week so i need to figure it out a little at least. Any tips on how to start without it taking up a huge chunk of time that i need for other assignments?

1 Upvotes

14 comments sorted by

2

u/Rabbit_Brave 17d ago edited 17d ago

What database are you using? Something like sqlite?

Whatever it is, if you want to do it the traditional way, then you need to look up the documentation and the c api for it, e.g. https://www.sqlite.org/cintro.html and https://www.sqlite.org/quickstart.html for sqlite.

[edit]

I was just thinking, if this is an early programming course, then "database" may just mean reading and writing files in any format of your choice. In which case, I guess begin by defining structs for each type of entity in the hospital, and then write a function for each that encodes the data in a string, and another function that takes a string and fills in a struct.

1

u/Horror_Preference208 16d ago

So we have learned jow to use sqlite so it does refer to an actual database. I honestly don't get what half the words that i saw in the comments. This is what the assignment is saying. Task 2 is pretty straightforward. Task 3 has me lost, but i am sure it cannot be as hard as people are saying because we litr just learned printf weeks ago

2. Database Design Design a relational database for managing hospital information. The database should contain appropriate tables such as: PATIENT  DOCTOR  DEPARTMENT  APPOINTMENT  Students should: Define appropriate fields and data types.  Identify primary and foreign keys.  Insert sample records.  Retrieve records using SELECT.  Update and delete records.  Use JOIN queries to retrieve related information.  Use aggregate functions and GROUP BY where appropriate. 

3. C Programming Develop a menu-driven C program to provide a simple console-based interface for managing hospital information. The program should provide suitable operations such as: Add a patient record  Display patient information  Search for a patient  Display doctors by department  Manage appointments  Display a summary of records  Exit the program  The program should demonstrate appropriate use of: Variables and data types  Input and output  Operators  Decision-making statements  Loops  Functions where appropriate  Input validation 

2

u/knouqs 17d ago

Geez, that's a tall ask for someone with only beginning C skills. Do you know anything about databases? What other knowledge do you have that would make it easier for us to direct you to a solution?

1

u/as400rocks 17d ago

You have to be kidding? You are using C? Note Python or Java or even C++?

1

u/Mediocre-Pumpkin6522 17d ago

If C is good enough for SQLite itself...

2

u/FreeLogicGate 17d ago

There's nothing wrong with C, but for a lower level course, there's no way a reasonable teacher would expect students to be writing their own persistence system, and then on top of that a multiuser networked system that has some form of client application.

1

u/Mediocre-Pumpkin6522 17d ago

The OP is vague but taking it literally

retval = sqlite3_open("test.db", &db);

will create test.db if it doesn't exist and return the sqlite3* handle. If 'make a database' includes designing the necessary tables, writing the SQL statement to create the table(s) and so forth the OP is hosed. Python isn't going to help in that case.

1

u/rsham004 17d ago

Use and embedded library to use sql commands to create tables. One is selected lite.

Just start and you will get there.

1

u/FreeLogicGate 17d ago

Seems like you got typo'd there, but i'm sure you meant sqlite.

1

u/rsham004 17d ago

Yes typo and I meant that. Grr sorry about the typo

1

u/BusinessStrategist 17d ago

Google "software architecture."

You need to think at the "systems level" to figure out how best to achieve your software solution.

1

u/FreeLogicGate 17d ago

I am going to guess here that your teacher expect you to use a SQL database. The advantage of that is that defining tables can be done with SQL code, and your client code can assume the structure of the tables. Probably you want to use either sqlite or mysql/mariadb. There is a C library client for both databases. There are some C++ wrapper libraries that exist, but if this is a pure C class, I'm guessing the expectation is that you'll just use the client library. The code isn't all that difficult, but way you get access to those libraries depends on your workstation OS.

The main difference between the 2 is that sqlite is meant to be used as an embedded database, so it has no separate server. The sqlite files are all going to be local.

With MySql/Mariadb, you can easily run the database in an official docker container, and the client code then connects to the database using either the network or optionally using a socket.

I would suggest you clarify with the teacher, what she expects, because writing your own persistence layer sounds like it could be a lot of work, and doesn't even begin to address, the multi-user/ network user requirements, whatever is meant by that.

1

u/jacksonanna373 14d ago

Start with the database, not the whole hospital system: make the tables and a few sample rows, then get SELECT/JOIN working. After that, make one C program open SQLite and run one query. Ask what network-connected computers means before you build anything networked.