{"id":14960581,"url":"https://github.com/atennop1/relationaldatabasesviaoop","last_synced_at":"2025-10-24T18:31:56.017Z","repository":{"id":166928399,"uuid":"641591323","full_name":"Atennop1/RelationalDatabasesViaOOP","owner":"Atennop1","description":"Simple OOP library for using relational database and having fun","archived":false,"fork":false,"pushed_at":"2024-08-04T17:26:33.000Z","size":14442,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T03:38:23.644Z","etag":null,"topics":["csharp","database","databases","library","nuget-package","nuget-packages","oop","orm","package","relational-databases","sql","unity","unity-package","unity-plugin"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Atennop1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-16T19:48:36.000Z","updated_at":"2025-01-07T05:31:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"bc68efe8-4f73-498c-8ab9-2d22271ff7f8","html_url":"https://github.com/Atennop1/RelationalDatabasesViaOOP","commit_stats":{"total_commits":65,"total_committers":2,"mean_commits":32.5,"dds":"0.29230769230769227","last_synced_commit":"a73c2ae12c87b9d3e0f55406195621f08dd9552c"},"previous_names":["atennop1/oop-sql-library","atennop1/relational-databases-via-oop"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atennop1%2FRelationalDatabasesViaOOP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atennop1%2FRelationalDatabasesViaOOP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atennop1%2FRelationalDatabasesViaOOP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atennop1%2FRelationalDatabasesViaOOP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Atennop1","download_url":"https://codeload.github.com/Atennop1/RelationalDatabasesViaOOP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238024405,"owners_count":19403836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","database","databases","library","nuget-package","nuget-packages","oop","orm","package","relational-databases","sql","unity","unity-package","unity-plugin"],"created_at":"2024-09-24T13:22:33.737Z","updated_at":"2025-10-24T18:31:49.874Z","avatar_url":"https://github.com/Atennop1.png","language":"C#","readme":"﻿# **Relational-Databases-via-OOP**\n\n![badge](https://img.shields.io/static/v1?label=Language\u0026message=C%23\u0026color=blueviolet\u0026style=for-the-badge)\n![badge](https://img.shields.io/static/v1?label=architecture\u0026message=Pure-Model\u0026color=red\u0026style=for-the-badge)\n![badge](https://img.shields.io/static/v1?label=Paradigm\u0026message=OOP\u0026color=green\u0026style=for-the-badge)\n\n## **About project**\n\n- This is a simple library for work with relational databases that I made as part of my learning new things in programming and **strict OOP Research**\n- In fact, this is just a wrapper over another library - [**Npgsql**](https://www.npgsql.org/)\n- The library contains classes for using basic SQL commands(CRUD), but allows you to execute any command in any mode\n\n### **Specifics**\n- Project using **OOP** and **SOLID**\n- Procedural algorithms of SQL request building designed to be **true OOP**\n- Clearest **DI** and **SRP**\n- My first library that I published\n\n## **How to install**\n\n### **Via NuGet into C# project**\n\n```cmd\ncd DirectoryWithYourProject\ndotnet add package RelationalDatabasesViaOOP\ndotnet restore\n```\nOr you can visit [**package page on Nuget**](https://www.nuget.org/packages/RelationalDatabasesViaOOP) and install package from there\n\n### **Via UPM into Unity project**\n\nFirst make sure you have standalone Git installed. Reboot after installation.\u003cbr\u003e\nIn Unity, open \"Window\" -\u003e \"Package Manager\". Click the \"+\" sign on top left corner, then \"Add package from git URL...\" and paste this: ```https://github.com/Atennop1/Relational-Databases-via-OOP.git```\n\n## **How to use**\n\nA little warning for those who don't know:\u003cbr\u003e\nRelational databases are databases **based on the relational data model** and SQL is a **relational database query language**. In the code of this library, you will not find a single mention of SQL, because all components **provide work with relational databases**, executing and building SQL queries in their implementation.\n\n### **RelationalDatabase**\n\nTo get started, you will need to create the RelationalDatabase and EnumerationStringFactory components. The first one allows you to query a relational database in any mode (NonQuery, Scalar, Reading and async versions of them) and has an IDatabase interface, while the second one is used by other components for convenience and has an IEnumerationStringFactory interface. You won't need it to run queries directly.\n\n```c#\nvar database = new RelationalDatabase(@\"Server=*your server*;Port=*your port*;User Id=*your user id*;Password=*your password*;Database=*your DB name*\");\nvar enumerationStringFactory = new EnumerationStringFactory();\n```\n\n### **RelationalDatabaseValue**\n\nAlso, for all components, you will need objects of the RelationalDatabaseValue class, which has the IDatabaseValue interface and is a name-value pair with validation, isolation and other cool things ;)\n\n```c#\nvar value = new RelationalDatabaseValue(\"first_name\", \"Anatoliy\");\n```\n\n### **RelationalDatabaseDataWriter**\n\nRelationalDatabaseDataWriter allows you to write data to your relational database and has the IDatabaseDataWriter interface. It only takes 2 arguments: the name of database table and the IDatabaseValues to be inserted.\n\n```c#\nvar relationalDatabaseDataWriter = new RelationalDatabaseDataWriter(database, enumerationStringFactory);\nIDatabaseValue[] values = { new RelationalDatabaseValue(\"age\", 19), new RelationalDatabaseValue(\"first_name\", \"Anatoliy\"), new RelationalDatabaseValue(\"last_name\", \"Oleynikov\") };\nrelationalDatabaseDataWriter.Write(\"humans\", values); //equals to \"INSERT INTO humans (age, first_name, last_name) VALUES (19, 'Anatoliy', 'Oleynikov')\"\n```\n\n### **RelationalDatabaseDataReader**\n\nRelationalDatabaseDataReader allows you to read data from your relational database and has the IDatabaseDataReader interface. It takes 3 arguments: the name of the table, the names of the columns to be selected (optional, if you pass an empty array, then in the final query will be \\*), and the IDatabaseValues by which the data will be selected (optional).\n\n```c#\nvar relationalDatabaseDataReader = new RelationalDatabaseDataReader(database, enumerationStringFactory);\nDataTable dataTable = relationalDatabaseDataReader.Read(\"humans\", new string[] { }); //equals to \"SELECT * FROM humans\"\ndataTable = relationalDatabaseDataReader.Read(\"humans\", new[] { \"first_name\" }, new IDatabaseValue[] { new RelationalDatabaseValue(\"age\", 19) }); //equals to \"SELECT first_name FROM humans WHERE age = 19\"\n```\n\n### **RelationalDatabaseDataUpdater** \n\nRelationalDatabaseDataUpdater allows you to update data in your relational database and has the IDatabaseDataUpdater interface. It takes 3 arguments, of which 2 are required: the name of the database table and the IDatabaseValues by which the data will be replaced. The third argument is the IDatabaseValues that will be updated. If this argument is missing, all data in the table will be replaced, be careful.\n\n```c#\nvar relationalDatabaseDataUpdater = new RelationalDatabaseDataUpdater(database, enumerationStringFactory);\nvar replacedArguments = new IDatabaseValue[] { new RelationalDatabaseValue(\"age\", 20) };\nvar argumentsWhichChanging = new IDatabaseValue[] { new RelationalDatabaseValue(\"first_name\", \"Anatoliy\") };\n\nrelationalDatabaseDataUpdater.Update(\"humans\", replacedArguments, argumentsWhichChanging); //equals to \"UPDATE humans SET age = 20 WHERE first_name = 'Anatoliy'\"\nrelationalDatabaseDataUpdater.Update(\"humans\", replacedArguments); //equals to \"UPDATE humans SET age = 20\"\n```\n\n### **RelationalDatabaseDataDeleter**\n\nRelationalDatabaseDataDeleter allows you to delete data from your relational database and has the IDatabaseDataDeleter interface. It takes 2 arguments: the name of the database table and the IDatabaseValues by which the data will be deleted.\n\n```c#\nvar relationalDatabaseDataDeleter = new RelationalDatabaseDataDeleter(database, enumerationStringFactory);\nIDatabaseValue[] values = { new RelationalDatabaseValue(\"age\", 19), new RelationalDatabaseValue(\"first_name\", \"Anatoliy\"), new RelationalDatabaseValue(\"last_name\", \"Oleynikov\") };\nrelationalDatabaseDataDeleter.Delete(\"humans\", values); //equals to \"DELETE FROM humans WHERE age = 19 AND first_name = 'Anatoliy' AND last_name = 'Oleynikov'\"\n```\n\n## **Conclusion**\n\nNow you know how to install and use the components of this library. Don't forget that if the library's CRUD components don't allow you to execute the commands you need or don't allow you to do all the necessary actions in one query, then you can always use RelationalDatabase, which reduces command execution to one line and allows you to use the full power of SQL. Thanks for reading this and using the library. Good luck with your projects!\n\nThanks to my colleague and friend [**Farid**](https://github.com/Farid357) for the good renaming according to all the canons of OOP\n\u003cbr\u003eFrom Atennop with OOP and ❤\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatennop1%2Frelationaldatabasesviaoop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatennop1%2Frelationaldatabasesviaoop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatennop1%2Frelationaldatabasesviaoop/lists"}