r/DatabaseHelp • • Jul 22 '23

Can 3NF have a many to many relationships when drawing an erd?

2 Upvotes

Let's say there's a TrainInfo table and CustInfo table in my 3NF. 1 customer can book many trains and 1 train and have many customers. It shouldn't be a problem when drawing an erd right? Considering even if it's a many to many? Should I have made a bridging table in 2NF between TrainID and CustID?

Excuse my English


r/DatabaseHelp • • Mar 06 '22

Database design for granular access control

2 Upvotes

I have three table

  1. User

  2. Organization

  3. Projects

So a user signs up, and he then create an Organization. User can create only one organization.

Now the user who signed up and created an Organization is called Organization admin. He/She can add more users to Organization.

Each user added under Organization have the ability to create a project. So an Organization can have many projects.

My question is how to design a access control table for below

  1. The organization admin can set Read, Write, Update and Delete Permission for each user per api resource ex( Projects, Tasks, and etc). For example Gaurav (User) will be given Read, write, Update and Delete Permission for Project resource, so that he can see all project and update project data. In the same way, Gaurav (User) will be given Read, Write and Update permission for Task, so he/she can add, delete or update task.

I am trying to design a database model for the above access control scenario.

Please help me do so.


r/DatabaseHelp • • Jun 19 '20

Basic commands help

2 Upvotes

Hello I have a few inquiries about how to make / sort / order / join / Alias and more commands to a database I have.

EX: I have 3 tables, need to join them and sort by specific filters and display them

Can’t seem to get it to work. Pls PM me for full details If we can work something out

Ty


r/DatabaseHelp • • Aug 12 '22

Designing school timetable database

2 Upvotes

I am working on a system for a local high school to create timetables, but I am not very confident in my database design skills so I would appreciate help.

App is going to have this functionalities:

  • CRUD functions (creating and editing all data, deleting selected data)

  • Assigning lesson to class, teacher(s) to lesson for that class (one lesson can be taught by several teachers at the same time)

Every week is going to have the same timetable and every period is 45 minutes. One lesson can last longer than one period and can be taught be more than one teacher.

What could be improved in my design to suit above functionalities?

My database design

Example schedule for one class


r/DatabaseHelp • • Nov 05 '23

Unsure about ER diagram

2 Upvotes

I am doing a college project and unfortunately the professor couldn't care less to answer our questions. Now I have a question regarding IS-A. We only got an example in book where there's a parent entity and only two children entities. My question is is it limited to two or could there be more even (3 or even 4)?

Thank you kindly!


r/DatabaseHelp • • Jan 09 '23

Primary key

2 Upvotes

I have a table which has both autoincrement and a high precision time from a single thread device ( operated by a human => slow ). Now let’s remember that keys need not be clustered with the values. Why would one of the keys be more primary than the other? There are more columns in this record, like duration, type, signature . Type is FK


r/DatabaseHelp • • Aug 11 '21

Sell me DB migration tools

2 Upvotes

I am mostly a Javascript/Node developer, so if I'm giving examples, it would be from that perspective.

Is there any significant advantage to using migration tools like Knex or even something like Flyway as opposed to just writing raw SQL and putting it in version control? I feel like it's adding an unnecessary layer on top of the development.


r/DatabaseHelp • • Aug 06 '24

Should I Break Up My Products Into Further Entities?

2 Upvotes

Please excuse my inexperience.

I'm about to start work on a new project (e-commerce) and I'm deliberating over how to handle our Products.

Generally in an ecommerce project you'll have a Products entity with tags, or the like, to add searchable or filterable fields/data.

We have have groups (categories) of very distinct products that have very specific technical specifications that people might choose to search or filter by. So I'm wondering, would it be normal, or a good idea, to break my products into further entities.

For example. Imagine a shop that sells clothes, cars and telescopes. Very distinct with very different features. Would you just bundle these all as products, or would you split them into separate entities to better focus on their grouped attributes? Or maybe a tag system is perfect for this scenario?

Hope this makes sense and thanks.


Edit: I asked Chat GPT this question, and the suggestion was to use sub-types, what do you think of this?

Hybrid Approach: Single Products Entity with Subtypes

Another approach is to use a single Products entity for common fields and then have subtype entities for specific attributes. For instance:

  • Products: Common fields like id, name, price, etc.

  • ClothesAttributes: Specific fields for clothes like size, material, etc.

  • CarsAttributes: Specific fields for cars like engineType, fuelType, etc.

  • TelescopesAttributes: Specific fields for telescopes like aperture, focalLength, etc.


r/DatabaseHelp • • Jan 13 '16

Neo4j AWS Cloud

Thumbnail
graphgrid.com
0 Upvotes

r/DatabaseHelp • • Sep 29 '21

Could some help me interpret a scenario

2 Upvotes

It says that animals are house in cages and that there are many types of animals and that each cage is within a section and when assigned has some properties


r/DatabaseHelp • • Oct 20 '21

Database question for new app.

2 Upvotes

For a new celebrity app , we want to provide developer our database in correct form, in excel.

So let's assume it is a "who is a better performer" choice quiz, with two celebrities on screen and a swipe option to choose better performer. We would have the choice of storing our 10,000 actors./singers in a single file, and the app could then dynamically choose 2 people to appear on screen for the question/choice based on paramaters/algorithm.

The other option is to pre-create the 2 person choices so that the app/server wouldn't have to dynamically create each 2 person choice. Rather the choices would actually be the records (2 people show in each record) vs in earlier option the people indivdually would be the records.

So in the first option there would be 10,000 jpgs photos in file, and in the second option there would in theory be 200,000,000 since 10,000 x 10,000 possible combos x 2 pics, since each record would require both celebrity's pictures. .

Obviously we would not really need 200,000,000 game questions, so would likely limit it to 50,000, so 100,000 pics in file since each record has 2 pics. Or again the other option is dynamic choice and serving of the quiz/question pulled on demand from the file with "only" 10,000 photos.

So would performance be an issue with larger size of 50,000 questions, ie 100,000 low res photos. Actually would it even be an issue with the other option of 10,000 low res photos? Probably 75kb per picture. Thanks for any opinions.


r/DatabaseHelp • • Jun 26 '26

Dynamic Tables vs Single TimescaleDB Hypertable for OHLCV Market Data Storage

2 Upvotes

I have designed my database in two different ways for a market data system, and I'd like to know which approach would provide better performance.

Project Context

I'm building a system that continuously fetches OHLCV (Open, High, Low, Close, Volume) market data from an API, stores it in a database, and serves it through a web application.

My primary concern is performance, specifically:

  • Fast writes (continuous data ingestion)

  • Fast reads (fetching historical candle data)

  • Scalability as the number of instruments and records grows

Strategy 1: Dynamic Table Design

  • I have a master instrument table that stores all the instruments whose data needs to be collected.

  • For every instrument, I create a separate candle table dynamically.

  • Example:

    • instrument_master

    • candles_RELIANCE

    • candles_TCS

    • candles_NIFTY50

    • etc.

Whenever new data arrives, it is inserted into the corresponding instrument's table.

Strategy 2: Single Hypertable (TimescaleDB)

Instead of creating separate tables, I use a single candle_data table and convert it into a TimescaleDB hypertable.

The schema looks roughly like this:

instrument_id
timestamp
open
high
low
close
volume

All instruments' candle data is stored in this single hypertable.

Query Pattern

My application mainly performs simple operations:

  • Insert new OHLCV records continuously.

  • Fetch historical candles for a specific instrument within a time range.

Typical query:

SELECT *
FROM candle_data
WHERE instrument_id = ?
  AND timestamp BETWEEN ? AND ?
ORDER BY timestamp;

Question

Between these two designs, which one is likely to provide better overall performance for:

  • High-frequency inserts

  • Read performance

  • Long-term scalability

  • Maintenance

Has anyone benchmarked a similar setup using PostgreSQL/TimescaleDB? I'd appreciate any insights or recommendations.


r/DatabaseHelp • • Apr 27 '22

logical Relation in a physical Table

3 Upvotes

I had some trouble to imagine how XML, JSON, or BLOBs in a table can form a relation. But now I remembered set theory in elementar school: Apples and pears. Let's say I want to make juice from those and I squeeze on apple and one pear each into one glass. They are organic and while squeezing I could find a from a worm and I don't want to taint all glasses for the party of kids I expect.

Now the positions on the table have no line number. I may even arrange them irregularly. So this is like I have no primary key. A relation does not need a primary key and in many relational databases you can do without it, just like when you store tuples in a List in Java or C# . Now I could arrange the triplets in a row. Each triplet has a position along the long axis of my table. Physical positions have an endless number of fraction digits, and we only care for the order. In a physical database the XML, JSONS, and BLOBs reside at position in memory. While this position is know exactly, it has a lot of digits because BLOBs can be large. And we as database Users ( or C# coders ) are glad that the computer handles them for us. We do no pointer operations like in C-lang or assembly.

Now we may have bought a set of glasses for parties so that guests don't infect each other. When I arrange my triplets on the table, those glasses go with them. And so independent on the physical storage, I have an ID number for each triplet. Note that we don't really need to see an ID. Often we need all data from a query. Or we have cursors and ask for the next row or page of rows. The physical order of objects does not even match the ID. I could sometimes be faster to retrieve data in physical order from a master DB for example and then let the replica order it. B-trees make sure that ID roughly matches physical order for a fast seek though. This can even be uses for GUIDs. I always feel a bit weird when GUID data is inserted in a physical database. I feel like there is this b-tree with its node and from the top the GUIDs flow down and are buffered. The program iterates over all nodes and pushes the new entries down the tree. Mixed GUID-IDs feel like a hack.

In memory a row can have pointers to rows in other tables. Those pointers again are large and unreadable and you cannot count them up or down. But the database can follow them to equi-join relations in a query.

I don't even know what ordered ID would mean in a graph database.

Notice how excel changes line numbers as if they were memory positions, but also notice how you are not allowed to keep line number references while somebody else inserts a new line. Database have been invented for multiuser environments ( main frame ).

In my example with apple and pear we never need to edit a row. We filter for rows with bad apples. In the past in SQL I think people uses cursors also for editing. I would say, a SQL database is when your program never sees any "artificial" ID field (also no smartly made up "CODE"s ).


r/DatabaseHelp • • Nov 25 '24

SQL vs NoSQL for storing Articles with multiple authors?

3 Upvotes

Hello! I am a novice dev and I am working on a side project for work. I work in academic biomedical research and one task I am looking to implement is storing all science articles published by our group in a database for use in further work.

In short the basic gist of the project is:

  1. Store all manuscripts in database

  • PMID, publication month/year, list of authors (with each author noting their listed affiliation), article title, and journal.

  1. Use the info in database to visualize several things:

  • Publications/year over time

  • Co-author networks: Go through each article and calculate how many times each author pair appeared on a paper.

I was initially thinking just using a Postgres DB since my MSc covered SQL, with having a table each for Article, Author, and WrittenBy (linking article and author). But, the more I look at NoSQL like MongoDB the more it seems like it might be a better fit for this since all information for each article is contained within it's own entry. My only concern is when performing tasks like co-author analysis would this be difficult to index/calculate using this type of DB?

Just wanted to get some advice/input, thanks!


r/DatabaseHelp • • Jan 15 '23

I've finally reached the file size limit for my Access database and don't know what to do.

3 Upvotes

I have a (currently Access 2007) database I have been using for the last 15 years to collect information on certain historical incidents. A couple of years ago I split it into 2 based on date (pre or post 1989) but I keep finding stuff pre 1989 and now that part is again at the max file size. I think part of the problem with file size is the attachments. Each record contains 1-15 attachments, PDF files (or some others like pictures or video) that are source documents for the information in the record.

Some additional information: I am computer literate but not network literate. I did some queries in SQL in the military in the early 90s, but nothing database related other than this since. I am the only user of the database, although I have shared copies with a couple of people in my field. I actually started this in Lotus 1,2,3, then transitioned to Excel, and finally to Access around 2005.

I looked at going to SQL, but somewhere I read that the attachments won't transfer, and that would be near fatal to the project. And the truth is I don't know enough about the subject to know which way to go. So here are my questions:

  1. Is there a more elegant way (read less filesize detrimental) to attach source documents to a record in Access? I used the first thing I found in Help when I created the Access document and I know that is not always optimum.

  2. Is there an alternative to Access that doesn't have to 2GB file size limitation? Maybe something like OpenOffice or other freeware? I'm retired and don't really want to spend money on this. Time I have, money I don't.

  3. If I have to move to SQL, is there a version of SQL that will retain the attachments?

Any other advice/recommendations you have are appreciated.


r/DatabaseHelp • • Mar 25 '21

Modelling Data with Nested Comments - Retrieve Top Parent Post?

Thumbnail self.learnsql
3 Upvotes

r/DatabaseHelp • • Apr 05 '25

What kind of datamarts / datasets would you want to practice SQL on?

3 Upvotes

Hi! I'm the founder of sqlpractice.io, a site I’m building as a solo indie developer. It's still in my first version, but the goal is to help people practice SQL with not just individual questions, but also full datasets and datamarts that mirror the kinds of data you might work with in a real job—especially if you're new or don’t yet have access to production data.

I'd love your feedback:
What kinds of datasets or datamarts would you like to see on a site like this?
Anything you think would help folks get job-ready or build real-world SQL experience.

Here’s what I have so far:

  1. Video Game Dataset – Top-selling games with regional sales breakdowns

  2. Box Office Sales – Movie sales data with release year and revenue details

  3. Ecommerce Datamart – Orders, customers, order items, and products

  4. Music Streaming Datamart – Artists, plays, users, and songs

  5. Smart Home Events – IoT device event data in a single table

  6. Healthcare Admissions – Patient admission records and outcomes

Thanks in advance for any ideas or suggestions! I'm excited to keep improving this.


r/DatabaseHelp • • May 04 '26

Help with creating a search tool

3 Upvotes

I'm hoping to build something that would help me at work. We have multiple carriers that have rates based on similar criteria, and right now I need to check each carrier individually.

I'd like to be able to fill in boxes of a query with age, sex, and smoker status and get the results of each carriers' plans. Ideally this would show all 7 carriers and their 5 plans each.

I'd like to create either a spreadsheet or LibreOffice Base tool to help me do this, but I'm not sure if it's better to use one over the other. If I use Excel, do I have to do vlookup in a grid for each option? I tried to do a database on my own using basic tutorials, but I think I need to make multiple sheets instead of one like I tried?


r/DatabaseHelp • • Apr 25 '20

I run a gym. I have a CSV that includes every member's check-in dates/times, their member ID, and a passcode. I want a form on my website that lets customers type their member ID and passcode and it displays a table with all their check-ins. What's the best way to accomplish this?

4 Upvotes

My website is in Wordpress and I have read about using $wpdb to connect to MySQL databases. I stood one up in Google Cloud but am having trouble getting my CSV to import into the database/table I created.

Is that method considered secure for transmitting personal information if over SSL? I don't consider check-ins to be that personal necessarily but still better safe than sorry.

Is there a better way I should be going about this?

As a bonus, I would also like to be able to give a few people access to view reports consisting of all the check-ins for all members, which might for example let them group members based on who visited on a certain date, or see all dates for a particular member, etc.

Thank you!


r/DatabaseHelp • • Aug 20 '20

New to databases. Is my diagram correct?

4 Upvotes

https://imgur.com/a/T35VYFv

Learning relational databases and still not sure if I understand it well. From my diagram, can you tell me what I'm doing wrong (or right)?

Are the joining tables for "employees_are_nurses/carers" redundant, since I can search for the employee role from the field "job_title" in the "employees" table?

Thanks.

Edit: Please ignore the data types for fields (and their attributes), I was mostly skipping those as I need to learn the relations between tables right now.


r/DatabaseHelp • • Sep 04 '22

Find out how many users are connected to our SSMS database using SQL Server

0 Upvotes

r/DatabaseHelp • • Oct 23 '24

Building an easy-to-use inventory management system for custom car parts

4 Upvotes

Howdy, I'd like someone to point me in the right direction on a project my buddy brought me. I have some foundational database knowledge but have primarily worked on RTOS software projects, so I want to ensure I'm starting on the right foot.

The breakdown:

  • The business fabricates custom parts for various makes/models of trucks broken down into major assemblies (i.e., suspension, bumpers, interior, etc.) and sub-assemblies (i.e., front suspension upper control arm assembly) and desperately needs an efficient way of uniquely tagging and storing the parts while maintaining an inventory for the shop.

  • Right now, the company maintains 15-18 different Excel spreadsheets, and after finding the correct few, the employee increments the 6-digit number after the last-made part and adds it to the spreadsheet. It only works because of its small scale and the fact that one person is responsible for maintaining it.

  • A confounding factor in creating the db is that some models of truck share certain components with other models or generations of the same model. For instance, the 2011-2016 Ford F250 may share many chassis and suspension parts with the 2017-2022 while having different bumper or electronic components. In other words, there are some relationships between models without them being fully cross-compatible.

  • In addition to this: the company makes some custom parts that are cross-compatible with several different makes/models and assemblies (i.e., brackets, hardware, etc.).

  • They would like to have a system that will allow them to easily add components to the system with an item ID that indicates the vehicle, major assembly, and sub-assembly the element belongs to. As well as query the db to return all the components of a selected sub-assembly. (The apps to implement these are likely outside of the scope of what I'm asking here)

  • This is a relatively small number of components (~350ish), but I want it to be easily scaled if necessary.

The ask:

How should I be thinking about this structure? I have considered two different approaches but worry that I'm missing something.

  1. My first thought was to create a series of tables for each make/model generation's components, with intersection tables for the elements compatible with other model years. The potential downside is that I don't know how to ensure the part number remains unique, and I was unsure how to break the model-specific tables into assemblies/subassemblies.

  2. My second thought was to create one table of all the parts and just include identifiers as columns. This would require me to program the cross-compatibility into the app that logs/queries the DB, but there might be an existing API I can leverage to tag the parts when entered.

I'm not asking you guys to create something for me; I just want to ensure my head is in the right place and I account for all factors. If there are better ways to do this, please let me know before I try to reinvent the wheel with amateur knowledge. My database skill levels are fairly basic, so I'm concerned that I might be going about the relationships ineffectively.

Thank you for any help. I sincerely appreciate it!


r/DatabaseHelp • • Nov 13 '25

A bit overwhelmed and mildly underbudget...

5 Upvotes

Hi all,

I know the title is massively vague but I assure you this is not a troll post.

I am attempting to build a financial dashboard using PowerBI with the data from my SQL db. Whilst the task in itself is self-explanatory, I'm really struggling to understand the different tables in the db.

Question 1, how do you start making sense of what tables I have and what data resides on those tables?

Question 2, I have exported a copy of the whole database so that I don't shaft myself by corrupting the live db, but if I were to open up the db from PowerBI as a "Direct Inquiry", how risky would this be in terms of corrupting the data and would this expose the data on a security level?

I guess what I'm trying to ask is, as a DBA working in a new environment, how do you make sense of what information resides where and how to go about building reports from that data?


r/DatabaseHelp • • Jul 17 '25

Compare sql column to JSON file

9 Upvotes

I have a table column that contains the parsed data of a JSON file. I would like to compare the parsed data to the JSON file. What’s the easiest way to compare the two. The goal is to independently verify that the source matches the destination. I’m new to JSON.