Questions tagged [sql]

Structured Query Language is a language for interacting with relational databases. Read the tag wiki's guidelines for requesting SQL reviews: 1) Provide context, 2) Include the schema, 3) If asking about performance, include indexes and the output of EXPLAIN SELECT.

Filter by
Sorted by
Tagged with
0
votes
0answers
18 views

Create trigger that updates Table3 from an insert into Table1 that multiplied by a value in Table 2 in MySQL

I know this is probably more complicated than it needs to be, however, I would really appreciate some help. I'm trying to create a trigger in MySQL that will update the value in the Costs table when a ...
2
votes
0answers
40 views

Student report card management Python program

The program is designed to take data from a MySQL database, using mysql-connector-python, and print it as a table in Python using the texttable module. The program also plots charts based on the data ...
2
votes
1answer
31 views

Find coherent datetime ranges in postgresql

My Data consists of rows containing a Length/Duration in Minutes, a Begin & EndTime. The precision is 1min (or larger). the table looks something like that: ...
1
vote
2answers
87 views

Moving files according to paths in database

I'm trying to move a large number of files. I get the path of source and destination from database. It takes hours to move images, and I was wondering if there is a faster way for moving large ...
5
votes
1answer
61 views

PostgreSQL: Grouping and Aggregating on multiple columns

Problem Statement: I am working on this simple dataset from Kaggle. I have provided a snippet of data with only required columns in below table. Dataset is quite simple, it has all IPL (cricket) ...
1
vote
1answer
95 views

Beginner CRUD Console Application

I wrote this basic CRUD app + simple report so I could practice talking to a db directly. I purposefully avoided repository pattern and Entity Framework and only used a library to show the coming data ...
1
vote
1answer
70 views

Prevent Column Name Collision

I have been working on a series of posts about a library to connect to databases but most of the scenarios I have to resort to some "JOIN" the problem arose when two or more tables had some ...
7
votes
3answers
405 views

Schema design for user profile and transaction

I'm creating a schema design for a user profile and transactions. I am very new in data modeling and currently this is my design. The schema has multiple deposit ...
-2
votes
1answer
41 views

T-SQL Query Performance [closed]

The query below already has indexes based its execution plan but it is still under performant with larger datasets. Are the additional null checks needed and why? Do you see anything that can be done ...
1
vote
1answer
95 views

Database schema for discussion forum scraping

I'm scraping posts from various discussion forums and storing those posts, along with some metadata, into a relational database (SQL). My actual use case is a bit more complex, but I think I can give ...
0
votes
2answers
31 views

Table-Value Function with row-level-locking

I'm implementing row-level-locking on a MS SQL Server. The function I created below works, but even with a very small data set, it takes a significant amount of time to return the results. If I were ...
1
vote
1answer
53 views

Simple website sql database

I'm getting into backend with postgresql and I would like to know how much of my example would fit for a real website database, just for storing and then displaying it on website. ...
1
vote
1answer
135 views

Get result of a scalar-valued SQL function from C#

I do not receive files on holidays; I only receive files on regular days—i.e., non-holidays. I want to skip 2021-09-06 since that's a holiday (Labor Day) and I know I will not receive any files. ...
3
votes
1answer
83 views

SE Data Explorer: Users by City

I view users by city using this SQL query: ...
1
vote
0answers
61 views

ContactEditor - Excel VBA db app: Storage Library

ContactEditor uses Excel VBA as a prototyping platform for a personal information manager combining the "Model, View, Presenter" (MVP) pattern and a persistent storage manager. Fig. 1. Data ...
3
votes
1answer
89 views

VBA introspection library for SQLite

SQLiteDB VBA Library is a set of VBA helper functions for the SQLite engine. The primary motivation behind this project is to provide convenient access to extended introspection features. Because of ...
0
votes
2answers
77 views

Efficient way to build table within database or update it using C#

I have a headless application that does either of two things. If table does not exist within database create it and copy all the data over OR If table exists update it Now I usually use access ...
2
votes
3answers
210 views

Queries for storing and get information from postgreSQL

I have been working with postgresql where I am trying to get information from database, update, exists and much more. I have created a context manager for commit and to close whenever it is in ...
4
votes
3answers
1k views

Optimizing the insertion of 400 000 records in sqlite

I have the python script that creates a sqlite database and fills it with data (originally coming from a json file). At the time I execute the code below, my word ...
0
votes
1answer
25 views

Appending script from within function to header [closed]

I'm attempting to import an external script into an HTML file. The name of the js file that I want to import is hosted in a SQL database. Therefore, I am using a XMLHttpRequest to access the SQL ...
3
votes
3answers
69 views

Order a table by column and get row number

In my database, I have table wp_postmeta, example: ...
0
votes
4answers
78 views

Appointment database - design II

I want to create a database which gives an admin user ability to create schedule for other users to book from. This is second edition of this database schema. I would like to know if there are any ...
1
vote
1answer
45 views

Appointment database design - Schema

How would you go about designing a database for service appointment? Here is what i came up with so far. Let me know if there is a better way. Basically the admin should be able to build services list,...
-1
votes
1answer
55 views

IF SELECT statement will break SQL ACID Compliance? [closed]

My QA told me that I should not use IF SELECT before doing an UPDATE statement because it will breaks the atomicity of a ...
1
vote
1answer
155 views

SQL for precision and recall?

I have a table containing two versions of results for some predictors, one by human labeling and the other by machine predicting, and I want to calculate some metrics. ...
3
votes
2answers
47 views

Alter authorization on all non-system SQL Server databases

I am not very experienced with T-SQL and feel this can be done better. The script changes ownership of all "user" (non-system) databases to sa. Usage of a ...
4
votes
2answers
169 views

Using a transaction to create account records

This is my first time using commit and rollback. I just need to know if this is a proper execution of the functions for this particular situation: ...
0
votes
1answer
49 views

Evaluate my program with Java Mail + Sql + Swing

I'm 16 years old and no one to help me, no one to give any advice or constructive criticism, I'm aimless. I'll leave the link to my last code (github), a program that sends an email to everyone ...
2
votes
1answer
59 views

program that sends an email to everyone registered in the database

I'm 16 years old and no one to help me, no one to give any advice or constructive criticism, I'm aimless. I'll leave the link to my last code (github), a program that sends an email to everyone ...
1
vote
2answers
165 views

A discord.py bot that logs every messages sent in a discord server

Hello Code Review community ! I'm making a bot with discord.py that listens to every message sent in a server and stores it in a database that could be retrieved by admin/mod later. Here's the ...
3
votes
1answer
71 views

Archiving / Moving Data from one database server to another database server

I am working on an SMS marketing project based on Yii2 Framework (PHP 7.3 & MariaDb (innodb engine)) where we have to move the logs from different tables to the archive db, which is total a ...
3
votes
2answers
280 views

To-do app API made with Slim 3

I have put together the back-end (API) with the Slim framework (v3) and MySQL. In index.php I have: ...
3
votes
1answer
102 views

New in PHP OOP and need opinion am I doing it the right way

I am new to using PHP OOP and decided to start learning by converting something I wrote in procedural PHP. So now I need your opinion and recommendations for my first work. One of the main reasons I ...
2
votes
2answers
47 views

Complex reporting query suggestion needed for different approach as per latest Tsql format

We have recently migrated from SQL Server 2008 R2 to SQL Server 2017 web edition. I am not a SQL developer but enthuses to learn. Since many of our scrips are of old SQL format, I am searching for ...
1
vote
1answer
56 views

Calculate course module credits from individual assessment scores

I'm currently working on a grade calculator for a university (professionally), and I am wondering if anyone can suggest an improvement to the following query? Here is my database: The query returns ...
0
votes
0answers
25 views

MTG Metagame Schema

So there's another question about storing information about a trading card game, but in my situation I have to store not only raw tournament information but a lot of statistics I've extracted from it: ...
4
votes
1answer
111 views

Storing and confirming user input

I am a beginner, and I'm trying to secure a sign-login system on my website. Is my code good/enough to prevent SQL injection? THIS IS THE SIGN FILES This is the index.php that takes user input: ...
1
vote
0answers
23 views

Django Models for an ESL school

I am working on building a management interface for an ESL (English as a Second Language) institute, basically it is a language school where people learn English. I have prepared my models for each ...
2
votes
1answer
26 views

Getting new vs. returning customers in Postgres

I have this work task, to write a SQL query that would show how many of the active customers are new (= do not have prior transactions) as opposed to returning per a given period. There is nothing ...
-3
votes
1answer
44 views

Form a flat indexed array from a multidimensional result set [closed]

I want make my looped data into one flat array without associative keys. I have solved it with my code, but I think it is so crowded and not simple. This my code: ...
-1
votes
1answer
29 views

SQL JOIN QUERY with more than one items in common: Find the franchise pairs that operate together in more than one location [closed]

I have a table called dfmt that lists the location, revenue and franchise. I want to find the franchise pairs that operate together in more than one location. So far, I have a query that finds the ...
1
vote
1answer
36 views

Multiple functions connected to SQL

I have created a thread before regarding the similar code review I had before Previous code review - I have updated a small piece of advice I got from previous answer and I did realized I have ...
-2
votes
1answer
190 views

Query builder class pdo,sql

Need some advices to create class that handles sql query operations with given array (having full control of the array and obtaining record information). My code works properly (it is just example), ...
1
vote
0answers
54 views
0
votes
0answers
61 views

.net core console app read from external API and write into a database

I have a .net core console app that gets some data from an external API and inserts it into a SQL database table. It is working as expected but I wonder if you guys have any suggestions to make it ...
0
votes
0answers
29 views

how to rewrite sql query with subquery to find max element without using limit?

the question is here Return the name of the category that has the most films. There are 2 databases - film_category: ...
1
vote
3answers
79 views

Delete companies with the least number of flights

I have solved the task of Delete the companies that made the least number of flights. the visual table diagram is here. The exercise is here This is my source code -it's "arrow antipattern"...
5
votes
2answers
149 views

PHP: Simple SQL query builder

I've been lucky enough to get my first job as a junior PHP developer. I am concerned I'm not good enough. I would like to brush up on my coding skills and get as much constructive criticism as I can. ...
0
votes
0answers
8 views

View returning results from multiple tables

I have a DB2 SQL view created with below statement: The problem I am facing is kind of strange. When we do a select * on this view, it runs slow for the first few times every new session. But then ...
4
votes
1answer
164 views

Calculating the Percentage of a Pair Occurring Across a Lot of Lists

I'm looking for a way to speed this code up. It took about 4.5 hours to run on ~20k decks. I'm open to restructuring my SQL query, but feel adjusting the python would be more effective. The goal of ...

1
2 3 4 5
29