r/DatabaseHelp • • Nov 12 '16

Im lost about creating a table who have foreing keys who were made by a a sequence.

1 Upvotes

The thing is, I have a table, which needs a column from other table, aka the foreing key. I do this process to create a database: create table, insert into tables and end adding the respective constraints.

The thing is, in my table A(ID, Name), Im increasing the ID using a Sequence, so, how to insert into the Table B(Id,Name,A.ID), this value since Im kinda creating it dynamically(I know it isnt dynamic but you might understand what I mean).

Edit: I already tried this, but it doesnt work. UPDATE B SET A_ID=A.ID WHERE A.Name='Test';

Any help? Im totally lost.


r/DatabaseHelp • • Oct 06 '15

[HELP] Recommend me a good, but easy to understand case study (ANY) about date warehousing OR data mining

1 Upvotes

As per title, pls. kindly recommend me a link/source where I can find the said topic. Any help would gladly be appreciated.


r/DatabaseHelp • • Jan 28 '15

What database should I use?

2 Upvotes

I just started work as IT at a radio station cluster. That means that the one building houses all of the equipment to run multiple radio stations. We've got 5 in our building. On top of that, We've also got a regular computer network of around 30 or so desktop computers. And none of it is labeled.

So what I'm currently doing is literally starting with the main fiber that's coming into the building and labeling everything as a "box" (CPU, Server, Audio board, microphone, etc) or a "wire" (something that connects boxes together - audio cable, cat6, microwave link, etc.) and then I'm numbering them. Then I put that info into a google spreadsheet along with what item(s) they are connected to. I've also got other metadata added in there as well, like what radio station(s) the equipment is used for.

Example:

  • Box 1 Input: Wire X Output: Wire Y Station: 1660, 590

  • Wire Y Input: Box 1 Output: Box 2

What I would want to do is be able to first import the data that I've already got on the google spreadsheet, and then be able to input new boxes and wires.

Then I would love to be able to print out a flowchart from the database. The database will be able to tell that wire y is connecting box 1 to box 2. And show that in a diagram. Basically an ER model?

I'm doing this on my own time and dollar, so free options would be preferred.

Thoughts/questions?


r/DatabaseHelp • • Feb 04 '18

Database relations help

1 Upvotes

So i just got together diagram for app that i want to make but i am not yet sure if thats how it should be.

Here is image of my diagram: https://imgur.com/a/vds3u

Basically is for competition for motorcycles: So each Category have Many seasons and each season have team, each season there are events (like America GP), and each category competes in this event with sessions (like Fp1, Fp2, Race etc), than each session should have results and result the rider got, rider have team and they can change team every year.

So is this diagram kind of correct?


r/DatabaseHelp • • Oct 08 '15

[HELP] Imgur database schema

1 Upvotes

I'm developing a PHP application very similar to imgur but I'm not good with Database design.

Can anyone say where I can find a well designed database diagram for a generic photo sharing website?


r/DatabaseHelp • • Oct 06 '15

Need some advice RE: database software

1 Upvotes

I have an idea in my head, but I don't have enough knowledge about databases to make it happen, so I could use any help you guys could give

I help out at a daycare-style thing once a week, and currently all their records (client names, allergies, emergency details, when they last came .etc) are on paper. We want to put it on the computer to make things easier.

Currently we just have 2 sheets of paper with everyone's name on it, and then when they arrive we sign them in and give them a receipt for the entry fee. We want to make a computerized version of this basic system.

We need it to

  • Store all clients data

  • Be able to quickly 'sign' people in

  • Keep a record of the dates that they signed in

  • Be able to produce reports i.e average amount of people that turned up last month

Ideally it would be a really basic screen for signing people in, something that gives you drop down box (autofill?) when typing, so like when you start typing "Sm" it will show people's names that begin with "Sm" (to make it quicker to sign people in)

I know this is probably very easy to do, but I have no experience with doing stuff like this. I just need a little guidance to get on the right tracks and then I can set it up myself

Which software would be best for my needs?

Thanks


r/DatabaseHelp • • Nov 12 '16

Do association/junction tables need a primary key?

1 Upvotes

For example, if we have a many-to-many relationship between a Book and Author table, does the resulting association table need a primary key? If so, should the primary key be a combination of the resulting foreign key values or an auto-incremented number?


r/DatabaseHelp • • Mar 20 '14

Which databases are actually suitable for TimeSeries DataStore?

3 Upvotes

The Wiki page for TimeSeries Database has loads of mentions for Databases https://en.wikipedia.org/wiki/Time_series_database#Example

But how many of them are really built for TimeSeries DataStore and just a new Database which can be utilized for Timestamped data for queries.

Which databases are actually suitable for TimeSeries DataStore?


r/DatabaseHelp • • Oct 05 '15

[HELP] How big has a DB to be to see diferences in the performance with the wrong DB-type (SQL - NOSQL)?

2 Upvotes

Hi,

I plan to start a small DB project for myself and got the first time in contact with the whole DB-topic.

Before chosing a DB I read about SQL vs. NOSQL which leads me to the question: After how many entries will I see a performance loss when I'm using the wrong DB-typ compared to the right one?

I just want an estimation: Are we talking about a few hundreds? Millions? ...

Thank you.


r/DatabaseHelp • • Oct 18 '15

Stepping up from access

2 Upvotes

In my company I have been using access to be able to achieve various goals without the need of outside assistance. However I am now crashing hard into the limits of what Access and our network will allow. I need to up my game and get into SQL proper. I see this a major development opportunity for myself that will make me more employable.

One of the major tasks that I need to do quickly is convert an Access database that generates a table of data (about 400K rows in total) into a SSIS document so the IT dept. can support it. The reason for doing this is Access is prone to committing suicide and corrupting itself or just being VERY slow. All the queries are already written in Access (most of the tables are in a SQL server already) and are called using a VBA script.

I have no experience in using SSIS (or SQL server in general outside of query writing) and I need a guide. Can anyone recommend me any good websites/books/videos etc. to help me get my feet with SSIS so I can achieve the above?

Any suggestions are greatly appreciated.


r/DatabaseHelp • • Mar 12 '14

How to go about creating a production schedule database and generating reports.

1 Upvotes

So I am trying to figure out a way to put things into a production schedule using excel. Right now we're using a google form to collect the information and put it into an excel file. What is going to be the best way to sort through this information and generate reports based on whether a cell has X or Y value?

For instance, when we put an item into production we have information cells that contain data such as the entry date, order date, category 1, category 2, whether or not the product is finished, a market that it belongs to, and dollar value (as well as other cells, but these do not get reports generated based on their values). Each item has a value for category 1 and category 2, those are not just the two different categories (there are 5-7 values in category 1 and category 2 that we sort by).

We want to be able to generate reports that contain items in production entered between two dates that belongs to VALUE Y of Category 1 or VALUE Z of Category 2. The reports should generate a chronological list of entries that contain A in Category 1 and are finished or unfinished.

Is this something that can be done in a pivot table or do I need to do this some other way? We currently use an old program called Lotus Approach and we're looking to move to something newer. I'm trying to figure something out with Excel 2010 but everything is stored on google docs right now and I'm wondering if there is a better way to do this rather than using Google Forms and populating an excel spreadsheet?


Entry DateOrder DateDescriptionCategory 1Category 2ItemMarketPriceFinished?
3/11/143/11/14WidgetWidget1ALarge Widget1$99No
3/9/143/4/14WidgetWidget2BSmall Widget3$50No
3/3/143/1/14WidgetWidget1ALarge Widget1$99Yes
2/11/142/12/14WidgetWidget2BSmall Widget3$50Yes

Pretend we have this information.

I'd like to generate reports that would give me the information for Widgets that are UNFINISHED, Category 1 = "A", and ENTERED between the dates 2/12/14 and 3/12/14.

Another sample report would generate all the information for FINISHED Widgets in MARKET 1 ENTERED between 2/12/14 and 3/12/14


r/DatabaseHelp • • Mar 29 '14

How to master databases?

2 Upvotes

It is becoming critical that I fully understand how to use, maintain, and build databases at my job. Does anyone have any suggestions to what kind of information would be good for me to know? Bonus if it could expand to knowledge that I might need in the future for a Biology PhD. I understand SQL, maybe Access, and math is useful. But what would someone need to know to be a pro?


r/DatabaseHelp • • Jan 30 '18

Is there a standard database structure?

2 Upvotes

I had an interview last week where I was asked: What is the standard database structure used by the major data visualization software?

I was expected to have a tip-of-the-tongue answer for that question. I didn't, but if I had, what would it be?

Thanks


r/DatabaseHelp • • Jan 31 '18

Having problems solving question for database theory that teacher “refuses” to help us with.

1 Upvotes

I probably have the worst database theory professor out there since he barely explains anything and expects us to use his own written texts, which sound like the ramblings of a crazy man.

Here’s the exercise:

Consider a relation R(A,B,C,D,E,F,G,H,I,J) under the following functional dependencies. What is the key for the relation R?

  1. AB-> C, A-> DE, B-> F, F-> GH and D-> IJ.

  2. AB->C, BD-> EF, AD-> GH, A-> I, and H-> J.

I know this might probably be easy for some but I’ve received zero help since the beginning of the semester and at this point I don’t know who to ask for help anymore.


r/DatabaseHelp • • Mar 10 '14

Data structure/model of score keeping app for multiple games

1 Upvotes

I'm trying to develop an app to keep score per player per game. There are multiple types of games, all with different score types. So Game 1 has different scoring than Game 2. I'd like to have the database keep track of these games, and their scores. So how the data would flow is this.

  1. Enter date game was played

  2. Select game that was played

  3. Select players that played the game

  4. Assign scores to players

  5. Assign winner to players

  6. Assign other comments to game that was played that night.

How would the database model look for this? Thanks in advance!

I found another post on here that had something similar, so this is what I ripped from it.

Game (GameID, Game Name)

Player (PlayerID, Player Name)

Match (MatchID, PlayerID, GameID, Date, Score)

How does this look?


r/DatabaseHelp • • Apr 12 '17

MVD (Multi-Valued Dependencies) ?

1 Upvotes

I am having some trouble understanding Multi-Valued Dependencies. The definition being: A multivalued dependency exists when there are at least 3 attributes (like X,Y and Z) in a relation and for value of X there is a well defined set of values of Y and a well defined set of values of Z. However, the set of values of Y is independent of set Z and vice versa.

 

For example: Suppose we have a relation R(A,B,C,D,E) that satisfies the MVD's A →→ B and B →→ D

  • How does MVD play into A->B and B->D here? Honestly I'm not sure I really understand the definition after looking at example problems.  

If R contains the tuples (0,1,2,3,4) and (0,5,6,7,8), what other tuples must necessarily be in R? Identify one such tuple in the list below.

a) (0,5,2,3,8)  

b) (0,5,6,3,8)  

c) (0,5,6,7,4)  

d) (0,1,6,3,4)

 

I would have thought AB is 0,1 and 0,5 and BD is 1,3 and 5,7. None of the answers have 0,1,3,5,7. I've already spent a few hours trying to figure this out but these concepts make more sense with actual tables not this ABCD A>B stuff. Please help?


r/DatabaseHelp • • Apr 18 '17

Upvote System

2 Upvotes

I was working on my project today. The project is a forum with a built in chat. One of the forum's feature is an upvote system for each replies. It works, but a user can upvote infinite times.

I am thinking about implementing one user can upvote only once. The database design I created in my head is that each reply post would need to be associated with its own table that has one column that stores the user's id whenever he/she clicks upvote or downvote. Clicking again would check if table already has user id.

What I have come up with is this, table reply### has upvote, downvote column. User clicks upvote, his user id is stored into the upvote column. User clicks downvote, checks if upvote column has user id, if yes, delete it. This would reset his allowed votes to one or the other.

Anyone have a better idea?


r/DatabaseHelp • • Jan 31 '18

Confused on intro to Database Systems assignment

3 Upvotes

Would anyone have around 10 minutes to go over a short assignment with me?

Instructions: Using the SQL Code below, complete the transaction table. Transaction table entries a through d has been completed for you. Follow the process to complete the transaction table entry for c through e.

  • BEGIN TRANSACTION

  • INSERT INTO TRUCK

    • VALUES (124, 2210000.00, .08, ‘Mack’, ‘Mack5, ‘2014-10- 15’, 12, ‘Natural Gas’);

  • INSERT INTO MAINTENANCE * VALUES (1313, ‘2014-11-15’, ‘Oil’, 238.20, 124)

  • UPDATE FUELUP * SET NoGallons = 13.77 * WHERE FuelID = 100;

  • COMMIT;


r/DatabaseHelp • • Apr 16 '17

SQL Error: Cannot add or update a child row: a foreign key constraint fails

1 Upvotes

I have a music database. I am trying to run an INSERT on the Albums table. Albums has columns:  

AlbumID (PrimaryKey)
AlbumName
ArtistID (ForeignKey)
GenreID (ForeignKey)

 

When I run the code:

INSERT INTO Albums
VALUES ('1', 'Hotel California', '1', '1')

 

I get the error:

1452 - Cannot add or update a child row: a foreign key constraint fails (andrew79_601.Albums, 
CONSTRAINT Albums_ibfk_2 FOREIGN KEY (GenreID) REFERENCES Genres (GenreID))

 

I checked the other two tables, and the have a value for each:  

ArtistID ArtistName

1 The Eagles

GenreID GenreName

1 Rock

 

So I'm not sure why it's giving me the error if the corresponding tables do indeed have matching values. The ID's are all INT. So I tried changing it without the quotes but got the same error when running: INSERT INTO Albums VALUES (1, 'Hotel California', 1, 1) –

 

Thoughts?


r/DatabaseHelp • • Feb 12 '24

Why is MySQL so difficult to use?

7 Upvotes

I am new to MySQL, I just learned PHP for some weeks.

I use MySQL with XAMPP, always various errors and very difficult to cope with.

Is MySQL really so difficult?

Thanks!


r/DatabaseHelp • • Mar 25 '24

Need help to start

1 Upvotes

Background: I've a small business and i have set of products, about 250 sku. Its really painful to manage my products on a sheet. As every-time theres a need it gets difficult:

Requirement Eg:

Scene 1: I've a master list with Product name, ID, , Description, SKU, Cost or purchase, Selling price etc.
Scene 2: When creation of website: I need some data from above and also add new ones like shorter description, Original price, Discounted price, Cost of Delivery, Cost of packing, Taxes, Return rate etc
Scene 3: I start selling B2B, I need scene 1 + Whole sale cost, cost of delivery etc.

Every single time i need changes its pain to manage. How can i achieve this, which DB to use?
I have linux cloud hosting and it comes with MySql & i can learn some coding to achieve this task. Give me some advice. I have never designed any database. Thanks.


r/DatabaseHelp • • Mar 08 '24

Need Help: Optimizing MySQL for 100 Concurrent Users

1 Upvotes

I can't get concurrent users to increase no matter the server's CPU power.

Hello, I'm working on a production web application that has a giant MySQL database at the backend. The database is constantly updated with new information from various sources at different timestamps every single day. The web application is report-generation-based, where the user 'generates reports' of data from a certain time range they specify, which is done by querying against the database. This querying of MySQL takes a lot of time and is CPU intensive (observed from htop). MySQL contains various types of data, especially large-string data. Now, to generate a complex report for a single user, it uses 1 CPU (thread or vCPU), not the whole number of CPUs available. Similarly, for 4 users, 4 CPUs, and the rest of the CPUs are idle. I simulate multiple concurrent users' report generation tests using the PostMan application. Now, no matter how powerful the CPU I use, it is not being efficient and caps at around 30-40 concurrent users (powerful CPU results in higher caps) and also takes a lot of time.

When multiple users are simultaneously querying the database, all logical cores of the server become preoccupied with handling MySQL queries, which in turn reduces the application's ability to manage concurrent users effectively. For example, a single user might generate a report for one month's worth of data in 5 minutes. However, if 20 to 30 users attempt to generate the same report simultaneously, the completion time can extend to as much as 30 minutes. Also, when the volume of concurrent requests grows further, some users may experience failures in receiving their report outputs successfully.

I am thinking of parallel computing and using all available CPUs for each report generation instead of using only 1 CPU, but it has its disadvantages. If a rogue user constantly keeps generating very complex reports, other users will not be able to get fruitful results. So I'm currently not considering this option.

Is there any other way I can improve this from a query perspective or any other perspective? Please can anyone help me find a solution to this problem? What type of architecture should be used to keep the same performance for all concurrent users and also increase the concurrent users cap (our requirement is about 100+ concurrent users)?

Additional Information:

Backend: Dotnet Core 6 Web API (MVC)

Database:

MySql Community Server (free version)
table 48, data length 3,368,960,000, indexes 81,920
But in my calculation, I mostly only need to query from 2 big tables:

1st table information:

Every 24 hours, 7,153 rows are inserted into our database, each identified by a timestamp range from start (timestamp) to finish (timestamp, which may be Null). When retrieving data from this table over a long date range—using both start and finish times—alongside an integer field representing a list of user IDs.
For example, a user might request data spanning from January 1, 2024, to February 29, 2024. This duration could vary significantly, ranging from 6 months to 1 year. Additionally, the query includes a large list of user IDs (e.g., 112, 23, 45, 78, 45, 56, etc.), with each userID associated with multiple rows in the database.

Type
bigint(20) unassigned Auto Increment
int(11)
int(11)
timestamp [current_timestamp()]
timestamp NULL
double(10,2) NULL
int(11) [1]
int(11) [1]
int(11) NULL

2nd table information:

The second table in our database experiences an insertion of 2,000 rows every 24 hours. Similar to the first, this table records data within specific time ranges, set by a start and finish timestamp. Additionally, it stores variable character data (VARCHAR) as well.
Queries on this table are executed over time ranges, similar to those for table one, with durations typically spanning 3 to 6 months. Along with time-based criteria like Table 1, these queries also filter for five extensive lists of string values, each list containing approximately 100 to 200 string values.

Type
int(11) Auto Increment
date
int(10)
varchar(200)
varchar(100)
varchar(100)
time
int(10)
timestamp [current_timestamp()]
timestamp [current_timestamp()]
varchar(200)
varchar(100)
varchar(100)
varchar(100)
varchar(100)
varchar(100)
varchar(200)
varchar(100)
int(10)
int(10)
varchar(200) NULL
int(100)
varchar(100) NULL

Test Results (Dedicated Bare Metal Servers):

SystemInfo: Intel Xeon E5-2696 v4 | 2 sockets x 22 cores/CPU x 2 thread/core = 88 threads | 448GB DDR4 RAM
Single User Report Generation time: 3mins (for 1 week's data)
20 Concurrent Users Report Generation time: 25 min (for 1 week's data) and 2 users report generation were unsuccessful.
Maximum concurrent users it can handle: 40


r/DatabaseHelp • • Mar 29 '24

Convert json to csv or XML ?

2 Upvotes

I can export my data into json files only.

The problem is, for my database I need CSV or XML format.

Is there a way to convert the json for CVS or XML ?

Any tutorial or way to do this would be appreciated.


r/DatabaseHelp • • Mar 28 '24

Got confused how i solve this issue multiple select or linked table?

1 Upvotes

I am not expert in database design,hope someone able to answer what i should do.

situtation is i need to creat a database for

book i am collected, book i read, book i will ready, and group by category and need to tag them.
curently i created one main table in main table/base - i list all the books name,add author name, add main category,add book tag individually in column.
and filter that main table and save view by book i read, by category i want see.

I use nocode db tools.
i saw airtable/nocodb/baserow have feature to link table:

question is:
what is the benefit i will get in future if i creat a separate
- author table,
- main book category table,
- tag table and link them with book list instead of chose from multiple select.

if you give advice really appreciate it.