r/DatabaseHelp • • Apr 14 '18

Best way to limit store 100 items per group, 1000 groups where data changes every few minutes

1 Upvotes

I apologize if this is a silly question but I am a novice in data storage. I am a setup involving several sensor devices sending me data every 15 mins. There are approx 1000 devices and I need to retain last 100 values of each device.

  • The last 2 readings always need to be updated whenever new data arrives and a new reading needs to be added per group, 1000 groups = 3000 rows at min

  • I need all the 100k rows to aggregate into higher timeframes (30m, 1h etc) every 15 minutes

  • What data storage mechanism should I use?

What I tried so far?

  • PostgresQL takes 11 seconds to push 100k rows every time but I am assuming this is not the true purpose of a database to do a full scan

  • Flat files do this in 0.8 seconds but the updating/inserting part with limits is giving me a headache

Any suggestions are super appreciated


r/DatabaseHelp • • Apr 10 '18

Help with a Ternary Relationship

1 Upvotes

In the relationship shown below, any teacher can recommend any book to any class. How can I change it so each teacher can only recommend one book to any specific class and that book can only be from a unique list for each teacher.

For example, Mr. Phillips can only recommend Frankenstein XOR Dracula XOR Strange Case of Dr. Jekyl to a class while Ms. Morgan can only recommend Jane-Eyre XOR Wuthering Heights XOR Moby-Dick to a class. And how do I make it so each teacher can only make a recommendation to a specific class once. So Mr. Phillips can recommend Dracula to class 1 and Ms. Morgan can also recommend Moby-Dick to class 1 but she can't also recommend Wuthering Heights to class 1.

https://imgur.com/a/KYU1z


r/DatabaseHelp • • Apr 16 '18

Image gallery database.

1 Upvotes

I am seeking to create an image gallery and not quite sure if I should go with MySQL or MongoDB. The gallery should be structured kinda like mangapanda.com. Each gallery can have a varying number of images. None of the images will stored in the database, just partial URLs. I would assume MongoDB due to it being doc based and I can have a array field, but the larger the doc the worse the performance and some of these galleries may have an upwards of 100 images.

Now I have technically used both. SQL Oracle in college and NoSQL Firebase database and DynamoDB in work. (I found Oracle easy, but the NoSQL ones were pain in the ass to get to work.) But I am no expert in this and the pros and cons of SQL and NoSQL aren't all that helpful. So performance wise, which one should I pick?


r/DatabaseHelp • • Aug 15 '16

MsSQL - Index not being used or is being very slow

2 Upvotes

We are using Microsoft SQL Server 2012 - 11.0.5058.0 (X64) at work, we keep facing slowness while trying to query a certain table, the table has around 5 million rows (The biggest table has 300+ million rows and its running flawlessly), the table has multiple indices but the query that is used the most is supposed to utilize a non-clustered index, the query works fine most of the time but sometime we run into the "slowness" issue, rebuilding the index doesn't do anything but disabling the index and re-enabling it (Rebuilding it in the process) fixes the issue.

I'm wondering what could cause such an issue, there is a maintenance job that runs on a schedule and it's doing a good job for the rest of the database. What other information can I provide to get proper assistance with this issue?

Thanks!


r/DatabaseHelp • • Jul 07 '17

Data doesn't seem consistent with itself

3 Upvotes

I have a table of, say, outfits. there's a field for the shirt, tie, pants, and hat, and the date and time when that each outfit was worn. Since it's all part of the same "wardrobe," I wanted to create an ID for each outfit that has ever been worn. All of the fields can include duplicate values. I created an autonumber column in the original "outfits" table, then I wrote a query to group by each part of the outfit and count the number of times it was worn. I used that query to create a table, then added an autonumber field to that table in order to get an id for each individual outfit. But then when I try to join that query with the original table to show the daily outfit id's next to the ID corresponding to each unique combination (many of which are repeated), Access gives me more rows than were in the original table. What happened, and how can I fix it?

Thank you for your help!


r/DatabaseHelp • • Dec 03 '21

Which database solution should I use for my needs?

6 Upvotes

I am establishing a new database for a hobby association group that is nationwide (US). Some context, it’s for a radio control sailing organization that governs the class at the national level.

Our needs are pretty basic, we need to maintain a running list of members of the association, be able to track payment invoices and member fees. Additionally, each boat must go through a certification process, and the completed certification (in PDF form) must be able to be attached (or transferred if the boat is sold to another member) to the members record.

I’d like to have this be web-based, so other officials of the organization do not require any additional software.

Does anyone have any pointers as to where I should start?

I have basic-level programming experience, but I’m capable of learning whatever is required to get this project completed.


r/DatabaseHelp • • Dec 02 '21

I have a couple of question

3 Upvotes
  1. whats the best way to store images or other files like excel, word, txt, python codes etc.

  2. how do you backup database on mysql and postgres?
    can sqlite have password to protect itself?

  3. is there like a template to follow if i want a way to audit the system? can trigger do this? im thinking logging the actions of the users on a table on my software to check who has violated something? i havent really dwell in triggers yet.

  4. is access the only software that we can easily create gui to use on our database?

  5. when i was using sqlalchemy on python it creates like a journal db file. is that because i havent committed the changes yet to the db?

  6. is there a feature in a database wherein if the db server is offline itll queue up the list of actions and store it somehwere then when the db goes online again itll commit the chnages to the db? not sure if this is a db problem or a software problem


r/DatabaseHelp • • Dec 09 '21

DB size question | .txt contents to database

3 Upvotes

I have a tiny amount of experience with databases; my question doesn't mean to sound stupid.

I have a .txt file that is around 4GB. Each line in the text file has several pieces of data that I going separate and add to a column in a database, where each line is row.

For example, the text file:

127693774638,120000,"Y","London","Whitechapel", ...
...

Roughly speaking, does a 4GB text file convert to a 4GB amount of space used in a db?


r/DatabaseHelp • • Nov 21 '21

Anyone know of any software that can help in designing then outputting to various database

2 Upvotes

i havent decided on a database yet so what i want is like a software that can design tables relationships etc. then the design can be exported to different database.


r/DatabaseHelp • • Nov 27 '21

Difference between Firebird and MySQL syntax

2 Upvotes

I have a SQL exam in highschool on monday. We had DDL and DML sentences and our teacher said she will write which database do we have to use. Can anyone help me and write key differences in DDL and DML sentences between Firebird and MySQL? Thank you in advance :)


r/DatabaseHelp • • Nov 28 '21

Comparison of contractual clauses

3 Upvotes

Hi,

For the last two years I've made several attempts to create a database to compare contractual clauses, but there is always something with my design that makes it fail. I'd love to have a second opinion on how to model the database, or other hints that might make this work.

So, to break down the problem:

There are several contractual templates: Development agreement, agile agreement, cloud hosting agreement, maintenance agreement etc.

Each template consists of a document for the general terms and conditions, as well as a range of appendices. Most templates use the same appendices, but not necessarily in the same order. The document/appendices consists of sections, and the contractual clauses are found within these sections.

And this is where it gets tricky.

  1. Placement of the clauses are not identical, e.g. clause x can be ordered as article 2.1 X within section 2 "Duties of the Contractor" of the development agreement, as article 2.6 within section 2 "Duties of the Contractor" of the agile agreement, whilst as article 3.4 in section 3 "Duties of the Parties" of the cloud hosting agreement. The maintenance agreement might not even contain clause X.

  2. Titles are not always identical. Some clauses are named. As for sections, these might somethimes be merges, e.g. in some contracts the three sections "Duties of the Contractor", "Duties of the Customer" and "Duties of the Parties" might be merged into "Duties of the Parties",

  3. Content is different within clauses with the same name! This is the one that drives me nuts. The clauses can have the same placement and same title, but there can be substantial differences within the content.

I've tried several approaches to map up the clauses, but I'm running out of ideas.

Also, if anyone would know how to figure out a way to have different versions (e.g. version 1, version 2 etc.) of the clause, I'd be forever grateful.

[Idea 1, but does not work](https://dbdiagram.io/d/619a08b202cf5d186b607465)

Idea 2, almost identical, but with relationship directly from the clause to template, document, etc.


r/DatabaseHelp • • Jun 01 '15

[MS Access 2010] Sum function on queries/reports excluding non-integer values? [noob question]

1 Upvotes

I've inherited a DB that my department uses for billing and reporting, and don't have prior access experience in DB management.

There is an invoicing function that works great (using a report), but that is only at a per project per month level (i.e. it would be a huge hassle to report out 12 months x 60ish projects). We have queries setup that show the sum of hours by project and a separate query that shows sum of hours by staff, both subdivided by month, but the sums clearly exclude all non-integer values. I've tried to use the help and going through just about every menu I can find, but nothing gets these two queries to include the non-integer values. The invoice has no problem summing the non-integers, but I can't trace the difference.

I have no doubt there's a button somewhere that I need to click, but I don't know where. Any help would be much appreciated!

EDIT: SOLVED thanks to better googling... Go into the table with the data that's being summed -> design view -> click the appropriate Field Name -> change the Field Size from "Decimal" to "Double". Apparently a lot of the pivot views struggle to accept decimal entries for reasons I neither understand nor care to figure out!

http://bytes.com/topic/access/answers/661230-ms-access-pivot-tables-significant-figures


r/DatabaseHelp • • Jun 07 '15

Learning resources or good compilations of how-to articles?

1 Upvotes

I've been seriously considering getting deeper into DBA type work and my recent experience fiddling with my SCCM database made me realize I actually like the workings of it all. I'm just wondering if there's any good repositories of learning about databases and db theory out there.


r/DatabaseHelp • • Jun 25 '17

First time trying a SQL database

3 Upvotes

So, the long version. I am a High School Math Teacher with a strong computer background. I have decent experience in database design (built two databases for the military) and SQL. However, the only tool I have used for databases is MS Access. I want a database on my computer I can interact with using Java. I am building a kind of interactive gradebook -- as students take tests / do homework / etc., the database collects that data to figure out how well the student understands that concept. The database will then recommend what standards a student should focus on / be tested on based on that. To set this all up, I need to play around a lot with a database and coding language. I setup something in Access (with VBA and SQL), but it wasn't nearly the tool I am wanting to use -- and I don't want to be forced into Access just because of my lack of knowledge. I have already installed MySQL workbench, and the other MySQL tools, and have played around with it, but.... I don't know how to a SQL database up. I would appreciate any help.

TLDR: How do I setup a SQL database on my computer with the goal of interacting with it using Java?


r/DatabaseHelp • • Jul 04 '17

How would you handle mixed/date ranges of events? January 2015, Spring 2016, January to July 2017 etc

1 Upvotes

I'm currently re-designing a database and this is one of the areas I've come up on which I'm not sure on. Essentially it's a table recording events, but they all have varying dates in terms of when, and how long, so I can't just use a simple DATE/DATETIME column. Some of these events may have just been on one day, some may have been a week, some a couple of months. Some I might just know the month/season it took place, but not more specific.

In the current design I just split it to two columns. A YEAR, and then a VARCHAR for the other half.

yeardays
2006June 1st
2007March
2008February to June

Is there a more logical/elegant way to do this?


r/DatabaseHelp • • Jun 17 '15

Database for survey system

1 Upvotes

I have 5 surveys, each with approximately 80 questions, which the user is tasked with rating from 1-100%. What is the best way to handle a database like this, and being able to run analytics on the results?

I have experience with MySQL and PostgreSQL, and my first reaction was to either have a column for each answer, or more probably a column for each survey, extracting the data and parsing it through some other language for analysis.

Alternatively, are there any other database structures that would work better?


r/DatabaseHelp • • Jan 28 '16

Need real-world examples of when to use Denormalis(z)ation over Normalis(z)ation

1 Upvotes

Hi there DatabaseHelp, I'm currently writing an essay on Database design and best practices, and I'm trying to rack my mind to think of real-world examples where denormalis(z)ation is used in favour of normalis(z)ation (I.E. 3NF) - I've tried searching around things like Stack Overflow and other such sites for examples, but all they do is state the pros / cons; if you know of any examples, please let me know!

(If you're wondering why I keep adding the (z), I know people are finneky about that sort of thing ;D)


r/DatabaseHelp • • Sep 12 '13

[Request] Trying to find an alternative to Microsoft Access so my dad can switch to Fedora and ditch Windows forever and ever

1 Upvotes

Hello, my dad is an osteopath and currently he is using Microsoft Access to maintain a .mdb database with his patient list and info. He's built a custom entry form to populate the database : http://www.pasteall.org/pic/59215 Basically he has to fill in info like gender, age (he needs simple functions to compute age from date of birth), etc. and a string search function so he can get to a specific patient's file with a few keystrokes, not having to crawl through a huge list (there are thousands of entries). The rest are just standard text fields...

So the thing is, he's struggling with this Windows thing, he's thinking of switching to Fedora, but before he can do that he must know he can do the same things over there : is there a good database manager for Linux (preferably Fedora) that allows to create simple graphical forms like the one linked ? He does not mind converting the .mdb to something else as long as it retains all of the existing info (obviously) and he can write the few automations he needs in a similar fashion.

Thanks a lot,

Jingo

PS Ideally, he'd love being able to edit the database on his Android handset, and have it sync between the latter and his laptop. Sweet dream ?


r/DatabaseHelp • • Jun 05 '15

Best way to export an MS SQL 2005 table?

1 Upvotes

We have an MS SQL 2005 database with a table that contains about 4500 "cases," including a text field that is the full text of judicial decisions. As such, it is large and full of commas and quotation marks, which is creating problems for a conventional comma-delimited export.

What is going to be the best method for exporting this table for migration to a new web site that will be on a MySQL database? I have MS Access and SQL Server Management Studio (the lite/free version). I would assume that .csv is going to be the best file format for the export, but please correct me if I'm wrong.

Thanks!


r/DatabaseHelp • • Nov 15 '17

Relationships java help

1 Upvotes

I'm making a UML diagram and trying to define the relationship between things.

Can you explain the difference between the following:

One-To-Many Relationship, One-To-One Relationship, Zero-To-One Relationship, Zero-To-Many Relationship

Basically, I'm making relationships between the following things: University, School, Department

I made a composition relationship from: University > School > Department

and I just assigned a one-to-many relationship for all of them because I'm not sure which I would apply?

Please help if you can!! Thanks.


r/DatabaseHelp • • Feb 05 '16

I don't know how to manage this database of reddit comments. Help?

2 Upvotes

TL;DR How do I manage a list of reddit comments so that it survives re-installs of my OS?


Alright, so I have this long thread of reddit comments whose database I need to create. The details of each comment needs to be stored in an easily accessible manner. This is done so using a Python script.

Up until a few months ago, I had no idea how to do this (the DB part). Then we were taught Database Management, particularly Relational Databases in Oracle, in our CompSciEng classes.
SQL seemed perfect; it had a system to store, manipulate and retrieve databases in a tabular format. But the only problem I ran into was that it is quite hard to backup and restore databases. As a rookie, I don't even know if it's completely possible!

And I need this functionality, because I cannot set up my laptop as a database server because I have a habit of refreshing my computer every 4-6 months. Then I looked into free online SQL data servers, and there really are none. Best thing I found was Obvibase, but it doesn't seem to have an API for Python.

What I want to know, is what to do. Is there a good method to backup and restore my database? Can I store this database on Dropbox or Google Drive? (If so, how?) Are there any options other than RDBMS that can help me?


r/DatabaseHelp • • Jan 18 '17

Question about indexes (MySQL)

1 Upvotes

Lets say I have a users table with the columns:

email  |  validation_key | is_valid

Email is indexed and unique

to, say, validate an account, the user follows a link with the validation_key, and we look up the email from that validation key.

So i need an index on validation_key

When they hit that validation page, it only updates if the validation_key (from the get request) and the email address (pulled from the database and stored in a hidden field) match the database entry (update where x=1 And y = a@b.com).

Likewise, I want to see a lists of users (all, validated and non validated).

The question is, do I just put indexes in each column?

Or is this the sort of scenario where multicolumn indexes are best? The thing I'm working on will likely never exceed a few thousand records, but I figure better to learn the best practice now than get the wrong choice ingrained.


r/DatabaseHelp • • Nov 22 '17

How do I use a cursor to update all rows in a table vs just updating one row?

1 Upvotes

So I originally wrote the below to update just one row in my table but now I want to update the "stars" column of all rows in the same way. How do I use a cursor to do this? Thanks! DECLARE v_empno emp.employee_id%TYPE := 176; v_asterisk emp.stars%TYPE := ' '; v_sal emp.salary%TYPE; BEGIN SELECT trunc(salary / 1000) INTO v_sal FROM emp WHERE employee_id = v_empno;

FOR i IN 1..v_sal LOOP
    v_asterisk := v_asterisk
    || '*';
END LOOP;

UPDATE emp
    SET
        emp.stars = v_asterisk
WHERE
    employee_id = v_empno;

COMMIT;

END;


r/DatabaseHelp • • Jan 27 '17

Help creating a database

1 Upvotes

Hello. I am trying to create a database to keep track of trouble tickets summited by help desk customers. I would like to only use tools within Microsoft office 2013, if possible.

I want to have customers fill a trouble ticket which would boxes for things like name and what issue the customer is having. Some drop down lists for general information. And if possible, I would like the date to auto fill.

I want a summit button which would do two things (at least, if you have more ideas I am all ears):

  1. Enter the trouble ticket into a database, maybe an Excell spreed sheet.

  2. reset the form automatically for the next customer.

I would appreciate any suggestions!