Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [orm]

Object-relational mapping is a programming technique that allows applications to work with the data as objects, but store the data in a database as groups of simpler values.

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

How do you fix parameter sniffing on an ORM / Entity Framework Query?

We have a problem with plan cache bloat due to unparameterized Entity Framework queries. In cleaning some of these up we've seen dramatic reduction in SQL CPU usage. I'm inclined to go "clean up ...
BBaggins's user avatar
0 votes
0 answers
6 views

Defining hasMany self-associations in sequelize v7

export default class Folder extends Model<InferAttributes<Folder>, InferCreationAttributes<Folder>> { @Attribute(DataTypes.INTEGER) @PrimaryKey @AutoIncrement declare id: ...
Narayan Waraich's user avatar
0 votes
0 answers
30 views

Eager loading relational data without including link table data using KnexJS or TypeORM

I have Table A and Table B in my Postgres DB. The relations are built using link tables. Example: ab_link table record contains a_id and b_id. What I am trying to do is get the ObjectA from table A ...
JeffinJ's user avatar
  • 101
0 votes
0 answers
27 views

Database Design Suggestion for Ordering System

This migration was made using Prisma ORM and using MYSQL as the main database. This schema is exclusively made for an ordering system I would just like to ask for suggestions on whether or not the ...
Daniel Evans's user avatar
0 votes
0 answers
806 views

MySQL 8 taking 1000x times longer to execute this query vs 5.7 when ORDER BY is used

This query comes from an ORM (Laravel Eloquent) on a WordPress database. I upgraded to MySQL 8 from 5.7 (AWS RDS), and the performance went from pretty speedy to basically broken. API requests that ...
Will's user avatar
  • 1
-1 votes
1 answer
184 views

How to handle a constantly changing schemas and tightly coupled entities (ORM hell)?

Essentially my team's ended up in a situation where Object A, B, C, D, and E (greatly simplified *sigh*) are different Java objects and each is represented by a single table interconnected with other ...
ElderFuthark's user avatar
0 votes
2 answers
582 views

Is there an equivalent sql check to python's concept of truthy / falsy / bool?

I'm trying to find the usage of particular columns in a mysql database connected to python. Python counts the following to be 'falsy': Empty lists: [] Empty tuples: () Empty dictionaries: {} Empty ...
racitup's user avatar
  • 103
1 vote
1 answer
580 views

CTE clause not able to be used in final ORDER BY statement

Trying to order by distance using an input geometry t(x), while comparing to geometries from a JOINed table. WITH "nearest_groups" as ( SELECT groups.id, ST_Distance(t.x, locations....
Underwater_developer's user avatar
1 vote
1 answer
404 views

SQL Server and NHibernate - blocking occurs between two unrelated queries (distributed transactions)

there's a problem that I'm seeking your help with... There are two simple queries: DELETE a row from a table in a databaseA SELECT a row from a table in a databaseB using hints with (updlock, rowlock)...
Timbalero's user avatar
  • 111
0 votes
2 answers
131 views

Subquery into join issue

I'm trying hard as I can to transform my query to get rid of subqueries. I know its better to not use subqueries, but my first reason to change this query is because my ORM (Doctrine) isn't able to ...
Jakub Stibůrek's user avatar
0 votes
1 answer
386 views

MySQL id not saving in order (Laravel in production) [closed]

I'm really confused about this.. So, I created a Laravel app and hosted it on Heroku. I'm using ClearDB extension to be able to use MySQL. Problem is: when I save a new User on my DB, it is not being ...
GabrielLearner's user avatar
0 votes
1 answer
1k views

Using a full text index with PostgreSQL and Doctrine

I received the following error: SQLSTATE[54000]: Program limit exceeded: 7 ERROR: index row size 2728 exceeds btree version 4 maximum 2704 for index "fulltext" DETAIL: Index row references tuple (1,...
user1032531's user avatar
0 votes
1 answer
1k views

In general should we avoid using ORM's with Redshift

My team is considering utilizing Hibernate/Envers for a granular point in time rollback solution for Redshift data. I have heard that using an ORM with Redshift is not a good idea. Are there ...
mikelus's user avatar
  • 323
1 vote
0 answers
131 views

Weird MySQL column name issue

After trying to use the Propel PHP ORM on my database, I noticed that there is an issue with foreign keys. This is a table with foreign keys: CREATE TABLE `appusers` ( `AppID` INT(11) NOT NULL, `...
user265889's user avatar
0 votes
0 answers
1k views

help in designing a database for medical clinic keeping record of patient visit

I am making software for patients record keeping in a clinic . I have written a peewee model for setting up tables to store record of each patient visit and patient contact and a relative table that ...
Ciasto piekarz's user avatar
-1 votes
2 answers
624 views

Is there a non-syntactical guide for naming database columns? [closed]

Is there a guide or best case practise to help people on choosing the best database column names. I am not looking at syntactical naming conventions such as snake case, camel case or even singular or ...
tambakoo's user avatar
  • 101
2 votes
1 answer
109 views

DB design to avoid versioning inconsistencies between the application layer and the database layer

Usually there is a 1-1 mapping between an object in the application layer and a table in the database layer. This coupling leads to complexities whenever there is a database schema change and the ...
Jim's user avatar
  • 123
1 vote
1 answer
134 views

What and where to index, rapid increasing table postgres

I work as a software engineer with python and django. Currently I am struggling with a design choice made before my time. We have a transaction table that logs all customer activity. Due to the ...
Phteven's user avatar
  • 111
5 votes
2 answers
60k views

How to set a auto-increment value in SQLAlchemy?

This is my code : class csvimportt(Base): __tablename__ = 'csvimportt' #id = Column(INTEGER, primary_key=True, autoincrement=True) aid = Column(INTEGER(unsigned=True, zerofill=...
Farhaan Patel's user avatar
1 vote
1 answer
92 views

Can i make a relationship between two relationships in the database?

I am making a database system where there are patients, doctors, categories and medical records. doctor and patient has a relationship called treatments ( many-to-many ) patient and a relationship ...
ahmed nader's user avatar
6 votes
3 answers
5k views

How to model Parent -> Child -> Grandchild if the Child can be removed

I'm dealing with a set of relationships where the child can be removed, but I obviously don't want to lose the connection between the grandchild and the parent. I did think about marking the child as "...
fgblomqvist's user avatar
0 votes
1 answer
947 views

MySQL table not working after a few days of use

I have the following tables on MySQL server, 5.5.46: CREATE TABLE `locking` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `filename` varchar(255) NOT NULL, `timestamp` timestamp NULL DEFAULT ...
artaxerxe's user avatar
  • 113
1 vote
3 answers
431 views

How can I optimize a query where a IN clause is replaced with multiples UNION ALL?

I have a query like this: select * from slow_view where id = 1 union all .... union all select * from slow_view where id = 1000 -- 50 ids, exec time: 10.615 sec, This would run in a very ...
heapOverflow's user avatar
20 votes
2 answers
10k views

What's the overhead of updating all columns, even the ones that haven't changed [closed]

When it comes to updating a row, many ORM tools issue an UPDATE statement that sets every column associated to that particular entity. The advantage is that you can easily batch the update ...
Vlad Mihalcea's user avatar
2 votes
1 answer
200 views

Do ORMs provide interfaces for working with window functions?

Many of my friends as well as previous workplaces emphasized use of ORMs over working with SQL directly. I've been exposed to Laravals ORM (Eloquent), Silverstripe's ORM, Active record, and Entity ...
Zach Smith's user avatar
  • 2,390
0 votes
4 answers
694 views

Design Pattern to Reduce Number Of Columns

I have a table with 49 columns, which is already normalized. It seems kind of excessive, but since every field is part of a form and the main entity is the form there are no relations I can refactor ...
J. Pichardo's user avatar
1 vote
1 answer
67 views

Scalability assessment for a simple auditing system based on an ORM

I was asked to create a simple audit system for a Web application. Due to some constraints I have chosen a "dirt and quick" way. This was possible due to small activity in that particular application (...
Alexei's user avatar
  • 1,271
1 vote
0 answers
588 views

Performance of an index on a column which is always null

I'm using a custom ORM framework which creates a column for all tables in the database called 'owningObject'. The column is a varchar(255) and the value is always NULL. The ORM is also creating an ...
Nick Gotch's user avatar
1 vote
1 answer
358 views

Avoiding foreign key repetition on related tables in a relational DB

I have a simple DB schema describing certain objects that belong to a historical time period of a country and (optionally) a subdivision of that country at that period. The contrived UML class diagram ...
Crossfire's user avatar
  • 113
1 vote
0 answers
48 views

Trying to understand if annotations are necessary or not in ORMs

My previous thread was here https://softwareengineering.stackexchange.com/questions/328793/can-anyone-explain-this-one-to-one-one-to-many-many-to-one-many-to-many-conce but honestly I think it ...
The 29th Saltshaker's user avatar
2 votes
1 answer
9k views

Join second table based on third table with conditions

I"m using Doctrine for a website that has 3 tables to connect together. In simplest terms, they look like this Contractor - id - name ContractorJob - id - contractor_id - job_id - status Job - id - ...
MechEngineer's user avatar
0 votes
1 answer
215 views

SQL to DjangoORM query

I've model, class ModelA(models.Model): device_id = models.IntegerField() deal_sent = ArrayField(models.IntegerField) For given device_id, we can have a list of repeating deal_sent. For eg:- ...
Praful Bagai's user avatar
0 votes
1 answer
100 views

Consultants using old version of Hibernate ORM for new application - should I be concerned?

My company currently has consultants developing a Java-based application. They are using Hibernate ORM 3.5 (released 5 1/2 years ago in 2010) in this application. The back-end is SQL Server 2012. ...
SomeGuy's user avatar
  • 2,013
2 votes
1 answer
2k views

HQL pagination returns same result on different pages - with SQL

We have the following query in the server (using sql): Query query = this.entityManager.createQuery( "SELECT type, id, date, amount FROM Transaction ORDER BY type ASC"); The type field is ...
Ayelet's user avatar
  • 121
1 vote
0 answers
106 views

Type of relational/object-oriented database with improved joins for object graphs?

I would like to know if there is a specific name or term for the kind of database described below: I notice one of the biggest problems when working with relational databases and object trees/graphs ...
Erik Hart's user avatar
  • 510
1 vote
0 answers
2k views

Deadlocks due to foreign keys (MySQL)

We are in the process of creating a web application using mysql as a data source. We are using spring with hibernate as an ORM framework. We have hundreds of entities with relations (manyToMany \ ...
Urbanleg's user avatar
  • 365
5 votes
2 answers
8k views

Lower() vs ilike on postgresql

What I want to do is to check if value of column equals some string, but case insensitive. Is there a performance difference when using ilike without wildcards (percents) and lower() ? I was planning ...
korda's user avatar
  • 635
5 votes
3 answers
1k views

Replace relational database with "poor" design in software product with non-relational DB? [closed]

Edit: This question is about how to deal with many issues that arose from a overall system design, which made parts of the system deviate from common standards. For example, managing everything in the ...
Erik Hart's user avatar
  • 510
2 votes
2 answers
545 views

Do I need foreign keys in ORMs?

Object Relational Mapping (take ActiveRecord and Rails, for example) allows a programmer to define relations between models, and callbacks on delete. So my question is: do I still need to define ...
Vecchia Spugna's user avatar
4 votes
1 answer
690 views

The future of DBAs with ORM [closed]

I am an aspiring DBA (I'd say in ~3 years I would be ready to apply for a job) and I currently am a programmer. I relayed my future goals to a friend of mine who is part of an Agile SCRUM team in a ...
Mark LaREZZA's user avatar
1 vote
1 answer
87 views

Effectively modelling extended classes

I have 3 different types of content for a website, 'Article', 'Video', 'Review'. Each of those three types of content contain common fields and type specific fields. For this, I have created the ...
Aaron Murray's user avatar
0 votes
1 answer
225 views

Nullable One To Many w/Join Table - Indexing

I have a question regarding database design, I am working with PostgreSQL using Hibernate for ORM, the design I inherited includes the following tables users user_id (pk) user_name user_dob ... ...
DaveB's user avatar
  • 309
2 votes
1 answer
4k views

Multi-variance products

My current system houses different variants of Products in different tables; Productgroups Productcolors Productsizes Productmodels Products can reside under 1 Productgroup and can have multi-...
User2910293's user avatar
5 votes
2 answers
2k views

What are the advantages of a database design with single table for MtM relationships?

The database that backs our software product has a table design like the following: Positions ID Name Parts 1 One 12345 2 Two 12346 3 Three 12347 Collections ID ...
krolley's user avatar
  • 151
2 votes
1 answer
4k views

Java application unable to access Blob stream in Oracle after upgrade to 11g

This issue below might be an application problem, but I cannot seem to rule out a poor database setup, I was hoping to get some insights into potential database issues. I am maintaining a legacy Java ...
maple_shaft's user avatar
7 votes
4 answers
549 views

How to troubleshoot orm queries interfering with other applications

Well, it's hypothetical scenario but what I'm trying to understand is the path to go from a post-morten log (say, an SQL Server Profiler trace) to identify the code on a ORM situation. To make it not ...
Fabricio Araujo's user avatar
-1 votes
1 answer
3k views

Difference in between HAS MANY and BELONGS TO in Yii framework [closed]

I am new to the Yii Framework. I discovered HAS MANY and BELONGS TO in the documentation, however I am confused about these features. Can someone give some real life examples with a diagram that ...
newuser's user avatar
  • 681
5 votes
3 answers
2k views

How does NHibernate handle execution plan?

I heard from a podcast that there are no ORMs that have a good solution for execution plan reuse. It will lead to increased execution plan cache which affects the performance. How does NHibernate ...
Amir Rezaei's user avatar
6 votes
3 answers
2k views

Is the ADO.NET Entity Framework known for generating poorly performing queries?

This question is inspired by the comment posted to the latest ServerFault blog post: Are you guys still using LINQ to SQL? I know I can use SQL Server Profiler and/or the ToTraceString method to ...
Marek Grzenkowicz's user avatar
6 votes
4 answers
8k views

Why does this Entity Framework query perform so bad in MySQL?

Let me give you a little setup. We have a InnoDB table on MySQL 5.1 with close to 20 million records, no foreign keys, and proper indexes for queries we do. We are using the latest 6.3.5 MySQL ...
Nick Berardi's user avatar