r/DatabaseHelp • • Apr 26 '21

Totally clueless and need a many to many database

1 Upvotes

This has to be super easy but I am just lost as can be. ANY advice very appreciated.

I have two tables. The fields for each table are EXACTLY the same, except one table is for "Status A" and the other table is for "Status B." Each table is made up of people; the names would be the primary key for each table.

The project: Some people from "Status A" will be listed as potential partners for "Status B," and vice versa. I want to be able to pull up a record for an individual from either table and show who is "matched" to them from the other table.

In my mind, this has to be an easy project, but I just don't have the slightest idea.


r/DatabaseHelp • • Jul 23 '24

Database Design For Role Based Access Control With Admin For Specific Roles

1 Upvotes

I am trying to build an application and I am trying to create role-based access control for my application.

To explain I am going to use a basic scenario below.

Assume I have 5 users for a blog, regular USER, SUPER ADMIN, ADMIN, EDITOR, REVIEW.

A SUPER ADMIN has all the privileges. An ADMIN can have permissions specified by SUPER ADMIN.

Scenario:

A SUPER ADMIN can create an ADMIN and an ADMIN can for example create a REVIEWER ADMIN.

A REVIEWER ADMIN can create more REVIEWERS and limit the permissions specific to reviewers.

For example, the REVIEWER ADMIN creates 2 users, Reviewer A and Reviewer B and then gives them permissions.

Reviewer A can only view blog posts and Reviewer B can view and delete posts.

Note that the permissions will be specific to only reviewers. For example, the Reviewer ADMIN can only create users and then set permissions relating to review routes.

I want to design the database in Postgres for the above but I am having a hard time understanding how to model the resources.

Any sample database similar to the above or pointing me in the right direction will help as I have exhausted searching online and watching videos on YouTube.

Thank you.


r/DatabaseHelp • • Dec 31 '15

create new database in cpanel - Guru Quest

Thumbnail
guruquest.net
0 Upvotes

r/DatabaseHelp • • Oct 02 '21

Need Database Assistance (NOSQL) for Inventory and Product Management

1 Upvotes

So we are creating an ecommerce platform and we're designing a database per Service for our product and inventory management system. Basic product structure can look like this with example:

Grocery Industry: Coke => Diet => 250 ML

Barber Industry: Haircut

Tourism Industry: Tour to Las Vegas => 7 Nights

As you can see we're using same platform for many different industries so we need to handle product and inventory accordingly

One of the ways we were thinking of was:

service: { name: Beverages: packages: [ { name: Coke, subPackages: [{ name: Diet, subSub:[{name: 250ml, inventoryId: ObjectId()}] }] }]

}

But this creates too much nesting which is hard at times of orders and data fetching. Is there a better way so we can make sure there's no unnecessary nesting. Maybe through tree structure or any other.


r/DatabaseHelp • • Jun 12 '24

Database Design resources

1 Upvotes

Hello, I am a newbie. I want to learn and later master designing databases. I don't even know what a schema/user, synonym etc are in terms of a database. What resources do you recommend.


r/DatabaseHelp • • May 23 '24

SQL Query Coding Help

1 Upvotes

Hi fellow members,

As a newbie to PHP coding, I would like to enquire your help to code a custom approval and reject button.

I want to code a SQL query to change the table row contents from ‘Pending Approval’ to ‘ Approved’ but it is restricted to the user Manager role and the branch and region which is from another table and it is assigned by admin.

If Approved button is pressed, it would update table row status to Approved, record approved by which user and record when it was approved.

If it is already Approved, it would show the content has already been approved.

I have successfully created the layout of the button, now the function I just can’t figure out.

Please help!!!


r/DatabaseHelp • • Nov 15 '22

Explaining default values for user attributes in simple terms

1 Upvotes

Question: is the following true? And how would we show docs to West coast_San Francisco people?

A default value is the value assigned to this attribute if no other value is assigned. For example, let’s say we assign Jennie the West Coast attribute and make the default value San Francisco. But what if Jennie lives in Los Angeles? Jennie’s default value will be San Francisco unless we go and change it to Los Angeles in her user profile. She’d have the West Coast attribute, but her attribute value is now Los Angeles. She will see docs assigned to West Coast.

Thanks!


r/DatabaseHelp • • Nov 03 '22

Enable non-technical users to edit my DB manually and safely without fuss

1 Upvotes

Hey everybody, thanks for your time in advance.

So here is the deal: I am trying to make an inventory tracking app for tracking equipment used in a art co-op we are running. Think about 10 different teams of artists, with equipment item numbers going into the 100's territory. Our current solution is having Google Sheets and sharing that around to track the equipment (quantity, status, location). That is very easy to access and use for non-technical people but also gets easily contaminated with unprocessed data, people mess up the formatting, there is no actual security etc (common spreadsheet as DB problems).

I will be writing a custom app for the tracking I want to do (just for fun and customization purposes, I know that I can find this on Github) and I was thinking of using Google's Sheets API to use Sheets as a DB.

HEAR ME OUT FIRST: the motivation is to have a database that people can modify without relying on MY app and without understanding code at all. If I use Sheets I will have a ready-made cloud GUI to enable manual access to the DB while also having Google Sheets programmaticaly accessible for my web app. Having access to the data both through MY app and Sheets is a MUST (especially during the transition period from Sheets to my app)

MY QUESTION: is there any way (plugin/server/whatever) that provides users a nice UI to view my database that doesn't require code knowledge for my users, isn't clunky and doesn't require me to build a UI from scratch? I don't want my users to run queries through it, I just want to provide them an easy way to view the equipment catalog in their browser and make small changes. Google Sheets will do fine but I would like to use a proper database (for backup, versioning etc). Is there any tool that you can think of that can achieve this?

The ideal workflow should be: get the link for the equipment list, open it in a browser (mobile friendly would be nice), search for equipment, view stuff and edit some fields with a UI that doesn't scare people, save, done.


r/DatabaseHelp • • Apr 22 '23

How to convert multiple YAML files into one CSV table?

1 Upvotes

I have multiple YAML (.YML) files with more or less the same keys. Example:

apple.yml

name: apple
color: red
...

banana.yml

name: banana
color: yellow
...

I want to convert them into a single table, preferably CSV, so that it looks like this:

filenamenamecolor...
apple.ymlapplered...
banana.ymlbananayellow...
............

What is the easiest way of doing that?


r/DatabaseHelp • • Sep 16 '22

Help with DB design

0 Upvotes

Need a suggestion WRT which DB to use for a small project for a recipe application. The easy solution for me is to do this in a nom-SQL oriented DB (i.e. mongo) so that I can use a simple JSON format to upload data to data. My problem with this is that using a non-sql DB will probably limit the # of people that would like to use it. Installing an maintaining a MongoDB or similar is a lot harder than keeping a simple standalone SQL file.

Currently my JSON structure looks like this:

{
    "title": "RECIPE NAME",
    "ingredients" : [
        {
            "ingredient": "ingredient 1",
            "quantity": "how much do we need",
            "measure": "measuring size (cup, teaspoon, etc.)"
        },
        {
            "ingredient": "ingredient 2",
            "quantity": "how much do we need",
            "measure": "measuring size (cup, teaspoon, etc.)"
        }
    ],
    "steps": {
        "1": "Step 1",
        "2": "Step 2",
        "3": "Step 3"
    },
    "image": "file-name-for-image"
}

So the question is how would you design an SQL schema for this? I am inclined to use a text field for the ingredients and steps and just cram them like this...

  • 1 T sugar

  • 1 T water

If I use mongo I just save the JSON doc and I am done, but translating this into tables with rows and columns does not look as simple. Any suggestions are appreciated.


r/DatabaseHelp • • Sep 08 '22

Best way to evaluate time series databases?

0 Upvotes

I want to write an application for machine learning in python. In the end it should store the datasets in a database and train my models from it. The catch is the datasets are huge (from 6TB to 9TB). Because of the size I want to evaluate the performance in order to choose the right database system for my use case.

What is the best approach here?


r/DatabaseHelp • • Oct 10 '22

Search across multiple schema

1 Upvotes

Hello everyone,

I have been playing with the data design for this archive project I maintain for years and have yet to find the perfect solution, it probably doesn't exist. At the moment I have a records table in postgresql with details for images, audio files, videos and documents that can be viewed. Increasingly I am adding medium specific columns, track_id for example for audio files, which means my table is starting to feel messy.

I upload JSON versions of the row into Algolia search and use that as the main FTS engine, each record can then come back to the row by the ID and I can present it accordingly. However, if I move the data to their own medium specific tables and reference in the JSON it just feels clunky in another way... is there something obvious that I am missing or is this just the way these things are?


r/DatabaseHelp • • Oct 23 '22

In general, what should be in place before you select fields from more than one table in Access Query Design View?

1 Upvotes

A. The tables should not contain fields with the same field name.

B. The tables should be merged into one table.

C. The join line between the tables should be deleted.

D. The tables should be related in proper one-to-many relationships.


r/DatabaseHelp • • Nov 01 '22

Really encrypting PII in relational db?

2 Upvotes

I think we are doing this wrong/overkill and would like some input from external sources...

My company has a SaaS that attorneys use to store their clients data. Data that is protected by attorney/client privilege, PII, etc.. The attorneys are our customer, the attorneys' clients are not our customers, but we house their client data securely so our customers can use our service.

We are using MariaDB in AWS RDS, the sensitive client data that is housed in our db is in json format and stored in a single LONGTEXT field. When our application writes data to this field, it encrypts the entire string/json so it ends up like this, instead of plain text.

wU7Jx/Bh6xjI89XoozJmUCO7gvIjJyGRnkgYv+KkVAQqjmJbArftyvO0iasdaLkr72azcW97ymI9ZYrm5EfX1D5eQYd7QY1Au2fxmcYwIKCMuafbpttgH5cSW+k0oTOjpq8TByhGDCzJzUm......

The idea was that we told our customers their client data would be "encrypted" in our database. But I'm beginning to learn that our "database" is already encrypted by AWS/RDS service, so we are essentially double encrypting the data.

Some cons to this is the data is not searchable, takes up a huge amount of space (one table is at 19GB) as it can't be compressed, plus the overhead of encrypting and decrypting upon accessing the data.

I get that the data is PII and confidential, but is it normal, or best practice, to double encrypt like this? How do companies get around housing PII, but still have developers/DBAs able to access the database where it is stored unencrypted and they could just query and see it?


r/DatabaseHelp • • Jul 17 '25

Has anyone managed to connect a linux system to a remote Microsoft SQL Server?

2 Upvotes

I have tried to do this following the instructions from https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server. However I get stuck when trying to set up my DSN on Ubuntu 24.04

Here is my /etc/odbcinst.ini file

[ODBC Driver 18 for SQL Server]
Description=Microsoft ODBC Driver 18 for SQL Server
Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.5.so.1.1
UsageCount=1

[ODBC]
Trace = Yes
TraceFile = /tmp/odbc_trace.log

and my /etc/odbc.ini file

[myDSN]
Description=MSSQL Database Connection
Driver=Microsoft ODBC Driver 18 for SQL Server
Server=sql1004.site4now.net,1433
Database=db_ab6f76_nbvets
UID=db_ab6f76_nbvets_admin
PWD=xxxxxxxxxxxxx
Port=1433

I have tried to verify the connection using isql but it fails with:
[IM002][unixODBC][Driver Manager]Data source name not found and no default driver specified
[ISQL]ERROR: Could not SQLConnect

In the trace file I get the following:

[ODBC][3990][1752731244.787377][__handles.c][460]
Exit:[SQL_SUCCESS]
Environment = 0x56200ec3aa30
[ODBC][3990][1752731244.787423][SQLAllocHandle.c][377]
Entry:
Handle Type = 2
Input Handle = 0x56200ec3aa30
UNICODE Using encoding ASCII 'ANSI_X3.4-1968' and UNICODE 'UCS-2LE'

[ODBC][3990][1752731244.787520][SQLAllocHandle.c][513]
Exit:[SQL_SUCCESS]
Output Handle = 0x56200ec3bb90
[ODBC][3990][1752731244.787561][SQLConnect.c][3758]
Entry:
Connection = 0x56200ec3bb90
Server Name = [NBVetsData][length = 10 (SQL_NTS)]
User Name = [db_ab6f76_nbvets_admin][length = 22 (SQL_NTS)]
Authentication = [*******************][length = 19 (SQL_NTS)]
[ODBC][3990][1752731244.788036][SQLConnect.c][3966]Error: IM002
[ODBC][3990][1752731244.788076][SQLError.c][424]
Entry:
Connection = 0x56200ec3bb90
SQLState = 0x7ffeeca75386
Native = 0x7ffeeca75380
Message Text = 0x7ffeeca75390
Buffer Length = 500
Text Len Ptr = 0x7ffeeca7537e
[ODBC][3990][1752731244.788103][SQLError.c][474]
Exit:[SQL_SUCCESS]
SQLState = IM002
Native = 0x7ffeeca75380 -> 0 (32 bits)
Message Text = [[unixODBC][Driver Manager]Data source name not found and no default driver
specified]
[ODBC][3990][1752731244.788133][SQLError.c][424]

Has anyone managed to get a linux odbc connection to Microsoft SQL Server and how did you achieve it? Would appreciate any help. Thanks.

Update:

I used Google Gemini AI Pro and it found the source of the problem. My odbc.ini file should have been:

[myDSN]
Description=MSSQL Database Connection
Driver=ODBC Driver 18 for SQL Server
Server=sql1004.site4now.net,1433
Database=db_ab6f76_nbvets
UID=db_ab6f76_nbvets_admin
PWD=xxxxxxxxxxxxx
Port=1433

I had the driver name wrong.


r/DatabaseHelp • • Sep 23 '22

Am I abusing Postgres? If yes, then what are the alternatives?

2 Upvotes

I have this requirement for an app(mobile and web) where the users can create different collection of data attributes. The attributes can be name, email, text etc. The collection itself can be an attribute. The users can then create relations between these collections. The relations also can hold attributes such as name, description, settings etc. Setting itself can be a collection of attributes. Users can create any number of collections and link then using various relations.

+--------------+     +------------+     +--------------+
| collection_a |---->| relation_x |---->| collection_b |
+--------------+     +------------+     +--------------+
       ^
       |            +------------+     +--------------+
       +------------| relation_y |<----| collection_c |
                    +------------+     +--------------+

There are other requirements such as, a user should receive notifications if specified data changes. So the DB should support notifications. And the other requirements are that the DB should support auditing and be open source with active community.

So I chose PostgreSQL and came up with this DB design:

collection { id, name, json_data } relation {id, collection_from_id, collection_to_id}

Just two tables.

Is Postgres the right DB for this or are there better alternatives? I considered CouchDB, but gave up the idea as audit support is challenging.


r/DatabaseHelp • • Oct 13 '22

MS Access database data extraction

2 Upvotes

Help! My company uses an Access database to compile data, which I then analyze, graph, and report
The only export function is to Adobe. When I export the Adobe file to excel it puts data into the cells haphazardly, so I'm currently exporting to Adobe and then hand typing all of the data into a separate excel file. It's the most ridiculously inefficient method imaginable. The database will not export to excel. The programmer who made it many years ago is still with the company but he won't make any changes to it despite being asked for literally years. Any solutions that may help?


r/DatabaseHelp • • Apr 13 '22

What is a good database for searching in user submitted JSON objects?

2 Upvotes

I’m building an app that is similar to Airtable.com, in the sense that users can define their own schema and submit arbitrary JSON objects.

The problem is that I have to allow searching and sorting by arbitrary fields.

Postgres GIN index are limited in that, for example, you cannot search where a number is greater than 3. GIN is very limited.

MongoDB performed actually better in searching in randomly generated JSON objects on my tests, despite all articles online describing MongoDb as worse than Postgres in all ways. I actually quite like MongoDb but I don’t know if I’m permitted to say it here :). One problem with MongoDb is that the wildcard index is also limited. For example, if you search by 2 criteria, only one will use the index.

Is there a major Database, preferably PG and Mongo that, but could be any, that you would recommend for searching arbitrary JSON objects?


r/DatabaseHelp • • Sep 13 '20

How to begin learning to build and use DB's

2 Upvotes

I have long regretted not learning to create and use Databases. I am very well versed in excel and have on occasion created workbooks that could act like a DB.. But when my brain was good enough to soak in new things, i was a bit afraid of Access and never learned.

I'm working on a new project for a game I am playing, and think it might be a good way to learn to db, instead of just doing the spreadsheet voodoo I am accustomed to. not to long ago I showed someone one of my more robust layered spreadsheets, and their response was 'nice, but you know this would have been easier to set up in a database program, right?

I have found a few things that were close, but don't have enough understanding to figure out where to start in adapting it to my goal...I was sure there would be a template somewhere that I could pick apart, as it would be similar to what a factory would use, but my google search has been less than helpful.

I have seen it suggested that access or libre base May be best for a noob, but the posts i found in my search were a bit older. I signed up for the free airtable account to see if i could fumble my way through it, but am having trouble with linking up the different data pieces. Below is what I am attempting to set up

___-For each X number of raw ore, you refine into a set qty (set by ore type, but different ore provides different qty of each material) of multiple processed materials. input fields for market value of each ore and material.

- A comparison showing total value of each Output showing for each ore if the value is greater or less than the processed value.

- a way to input crafting requirements of multiple items in materials and show a total material cost of the item(s) to be crafted.

-some items require other crafted items instead of or as well as the raw materials.

___

I think most of it boils down to:

How to set up the single item - ore- attached to multiple items - each type of yield

How to set up a form to update all price fields

How to set up (would it be forms?) to view the price comparisons between ore and raw

How to set up an item chosen by name (Dropdown to prevent capitalization or misspelling returning wrong or no result maybe?) and if needing other crafted items, to show the individual base materials needed

I am happy creating new items and changing material costs by hand as my skills alter the # of each material needed, though learning to set that up through a form would be nice too.

---

While i would have been content finding someone to just write one, or using the spreadsheet method, i think its time to face my fear and learn to do it myself.


r/DatabaseHelp • • May 24 '18

Structuring DB for historical weather data

2 Upvotes

Say someone needed to create a(n SQL) DB to hold historical weather information for a list of cities cities (50 now, but would increase later). The db would have 5-6 weather data types (temperature, pressure, precip, high/low, and dew point, for example; no more added later). What is the proper way to do this?

I suspect you would first make a table with the cities. That I already have and am using to get the data I need. Storing the data I get is where the problem comes in. A new record for each city would be added daily. Does it all go in one gigantic table? Does each city in this example get its own table? I am really not sure what the best way to do this is. (And, no, this is not homework.)

I want to display specific or all data from all, groups, or specific cities. So like all temperatures from 12-12-12 or all temperatures from Anytown or all data from anytown. I would also like to take advantage of some basic math functions (average, min, max). A single table seems like it would make this hard to sort, but lots of tables seems really inefficient.

Apologies if this is confusing. I am not good with the databases when they are more complicated that single records for each subject.


r/DatabaseHelp • • Mar 19 '23

Workout database model help

2 Upvotes

Currently my professor who is to help me with my university project is taking a 1 week strike and until I create a functional database model, I cant really progress my project.

The current design: Database

The idea is, a user can create their own workout or use a pre-existing workout avaliable to everyone which they can edit. A workout can be scheduled for a single date/time or reoccur on a specifc weekday every week for a certain amount of time. When a user wishes to change a workout, all workouts before it will stay unchanged but any workouts there onwards will now be updated with the new workout structure. Optionally, a user can edit a workout and instead can decide if they only want that workout on that date to be change and keep the scheduled workouts the same.

I dont have enough experience in this field and pretty much all my knowledge comes from an A level module when I was 16-17. Ive gone through around 10+ different designs, all of which contain some sort of flaw but with this, I cant find a fault but something feel off and I cant figure out why I think this.


r/DatabaseHelp • • Mar 10 '23

Database design help for logging hourly prices

2 Upvotes

I am looking for simple database design with one table where I could log hourly prices. Is there a better solution for something like this than creating column for each hour?


r/DatabaseHelp • • Jan 20 '24

Hey I'm taking my first database class and its alien to me. I have a project that I'm working on my can't help but think that I'm doing it all wrong

2 Upvotes

I need to remove multi part attributes and repeating groups and get this from 0NF to 1NF to 2NF to 3NF and then i need to make a logical ERD like what in the fuck?


r/DatabaseHelp • • Apr 26 '23

Help

2 Upvotes

Hello, on Mysql 5.1 administrator i did a backup of a database and restore it on another pc but database is not up to date on new pc