Jonovono
Jonovono

Reputation: 3425

How does git, for example, create the database they use?

Hi so I am working on a terminal application and would like to use a database. I am not sure the best way to go about doing it though.

So I want to have the program be able to install like you would git or with brew install etc. And then each person that installs it would have their own database which will be accessed via certain commands.

I'm just not sure what the best way to do this would be? I was thinking for each entry I would put in the database I could just create a file in a .directory?

Thanks.

Upvotes: 4

Views: 2959

Answers (3)

Ole Tange
Ole Tange

Reputation: 33748

You are most likely looking for SQLite.

Upvotes: 1

Riking
Riking

Reputation: 2491

Git has a much different "database" scheme than other applications. As visualized here, it has a .git directory, with a objects/ directory and a bunch of files named after SHA checksums. This is not a very good model to use for someone who is starting out.

If you want to use the Git filesystem, there are ways to do that (search for "git plumbing").

I'd recommend one of MySQL, XML files, or a filesystem format (keep in mind, if you run on Windows, anything below 4KB is wasting space).

Upvotes: 1

Greg Hewgill
Greg Hewgill

Reputation: 994629

The filesystem is actually quite a good database, suitable for storing a moderate number of documents with sizes ranging from tiny to huge. It's not relational (the only "key" is the file name), and it's actually closer to a "NoSQL" database than a relational database.

The Git database, in fact, can store all its objects with one object per file. However, for efficiency reasons, it was found that the access patterns required by Git were better served by combining many objects into one "pack" file.

Upvotes: 7

Related Questions