Jump to content

Some Newbie questions about databases.

Guest
Go to solution Solved by BobVonBob,

The file can be saved as whatever you want it to be saved as, it's just data. The structure will depend entirely on how you make it, for what it's worth I would suggest one large file instead of many small ones.

Hi, I'm thinking about writing a program that would keep records about people, I'd prefer writing it in C and I'd also like to encrypt the database. I would save 

data like DoB, email, phone number for every person individually and then I'd also have a structure for every "relationship"  (Husband, Wife, day of marriage if married and children if any)

 

So my question is, how would I save those records? I've only worked with stuff like fprintf.... So the files werent encrypted. What filetype would i need to use for that? I don't care for any compatibility with other programs and I'd prefer if there wasn't any. Would i need to save the record for every person/relationship in a separate file or would it be better if i have one big file containing all people?

Link to comment
Share on other sites

Link to post
Share on other sites

There is no encrypted file type, only encrypted data. In order to save encrypted data you would first encrypt the data, usually with a cryptography library, then write to a file/db just like you would any other data. In order to use that data you then have to decrypt it with that cryptography library, then use the data from there.

¯\_(ツ)_/¯

 

 

Desktop:

Intel Core i7-11700K | Noctua NH-D15S chromax.black | ASUS ROG Strix Z590-E Gaming WiFi  | 32 GB G.SKILL TridentZ 3200 MHz | ASUS TUF Gaming RTX 3080 | 1TB Samsung 980 Pro M.2 PCIe 4.0 SSD | 2TB WD Blue M.2 SATA SSD | Seasonic Focus GX-850 Fractal Design Meshify C Windows 10 Pro

 

Laptop:

HP Omen 15 | AMD Ryzen 7 5800H | 16 GB 3200 MHz | Nvidia RTX 3060 | 1 TB WD Black PCIe 3.0 SSD | 512 GB Micron PCIe 3.0 SSD | Windows 11

Link to comment
Share on other sites

Link to post
Share on other sites

50 minutes ago, BobVonBob said:

There is no encrypted file type, only encrypted data. In order to save encrypted data you would first encrypt the data, usually with a cryptography library, then write to a file/db just like you would any other data. In order to use that data you then have to decrypt it with that cryptography library, then use the data from there.

Yeah that's what i thought i would have to do but what filetype would the information be saved as before the encryption, just a normal ASCII file with each person having their own line in the file or each person having their own file?

I don't think i will need to delete records, just change some information.

I probably shouldn't have mentioned encryption since it isn't the problem I'm facing right now. 

Link to comment
Share on other sites

Link to post
Share on other sites

The file can be saved as whatever you want it to be saved as, it's just data. The structure will depend entirely on how you make it, for what it's worth I would suggest one large file instead of many small ones.

¯\_(ツ)_/¯

 

 

Desktop:

Intel Core i7-11700K | Noctua NH-D15S chromax.black | ASUS ROG Strix Z590-E Gaming WiFi  | 32 GB G.SKILL TridentZ 3200 MHz | ASUS TUF Gaming RTX 3080 | 1TB Samsung 980 Pro M.2 PCIe 4.0 SSD | 2TB WD Blue M.2 SATA SSD | Seasonic Focus GX-850 Fractal Design Meshify C Windows 10 Pro

 

Laptop:

HP Omen 15 | AMD Ryzen 7 5800H | 16 GB 3200 MHz | Nvidia RTX 3060 | 1 TB WD Black PCIe 3.0 SSD | 512 GB Micron PCIe 3.0 SSD | Windows 11

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, BobVonBob said:

There is no encrypted file type, only encrypted data. In order to save encrypted data,

you would first encrypt the data, usually with a cryptography library, then write to a file/db just like you would any other data. In order to use that data you then have to decrypt it with that cryptography library, then use the data from there.

For databases you can have encrypted at rest, its decrypted on the fly as data is requested.

 

You need to pick if you want to use an SQL database or a NoSQL from work and having millions of data points of financial data to work with I can tell you MongoDB is 100 times faster than MySQL in some cases

 

We have communications that will build an email say from multiple collections and these sorts of joins are slow on MySQL super faster on MongoDB

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

Link to comment
Share on other sites

Link to post
Share on other sites

That's the way to do it in an actual production environment, I was operating under the assumption that this was either a personal project out of interest or a class project where the objective was more to make a database than to make/support a product.

¯\_(ツ)_/¯

 

 

Desktop:

Intel Core i7-11700K | Noctua NH-D15S chromax.black | ASUS ROG Strix Z590-E Gaming WiFi  | 32 GB G.SKILL TridentZ 3200 MHz | ASUS TUF Gaming RTX 3080 | 1TB Samsung 980 Pro M.2 PCIe 4.0 SSD | 2TB WD Blue M.2 SATA SSD | Seasonic Focus GX-850 Fractal Design Meshify C Windows 10 Pro

 

Laptop:

HP Omen 15 | AMD Ryzen 7 5800H | 16 GB 3200 MHz | Nvidia RTX 3060 | 1 TB WD Black PCIe 3.0 SSD | 512 GB Micron PCIe 3.0 SSD | Windows 11

Link to comment
Share on other sites

Link to post
Share on other sites

42 minutes ago, BobVonBob said:

That's the way to do it in an actual production environment, I was operating under the assumption that this was either a personal project out of interest or a class project where the objective was more to make a database than to make/support a product.

It's a personal project that could turn into something more serious. I basically want to write a program where i could read from the database, make changes if needed, run queries and make a tex file with the queried data.

 

Now as far as I know if i decrypt the entire file queries would run faster but then the data would be at risk, right?

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Willi said:

It's a personal project that could turn into something more serious. I basically want to write a program where i could read from the database, make changes if needed, run queries and make a tex file with the queried data.

 

Now as far as I know if i decrypt the entire file queries would run faster but then the data would be at risk, right?

If you create 1 file you need to completely decrypt it before using it. As the amount of data increase things will slow down. If you go with many files or database (best option) You encrypt the values of each fields. This won't affect much the query speeds. Data will take more space on the disk but once loaded your program decrypt just before displaying the data.

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

×