Questions tagged [relational-database]

A relational database is a database consisting of relation variables (which are also called *relvars*, *R-tables* or just *tables*). The definition, manipulation and integrity rules of relational databases are based on relational operations equivalent to or similar to the Relational Algebra and Calculus. Relational database principles are the basis of a substantial part of data management theory and practice.

A relational database is a database consisting of relation variables (which are also called relvars, R-tables or just tables). The definition, manipulation and integrity rules of relational databases are based on relational operations equivalent to or similar to the Relational Algebra and Calculus. Relational database principles are the basis of a substantial part of data management theory and practice.

Targeted Questions

This tag is appropriate for questions concerning the relational model, relational and relational database implementation.

The SQL language is commonly used to specify relational database-designs and to define and solve relational database problems. However, DBMSs based on SQL are by definition not s and therefore not all SQL questions are relevant to the relational database tag. Questions specific to or its implementations should be tagged accordingly.

6790 questions
1
vote
4 answers

Can all SQL queries be represented in Relational Algebra, Domain and Tuple relational calculus

My query includes a having and count or all in. How are these represented in RA/DRC/TRC? Would I have to simplify my SQL query even more? Here is a simplified example: empl(employee (primary key), city) managers(employee (primary key), manager…
1
vote
1 answer

database supertype/subtype

I need to implement a database to track a parcel's location. There can be basically 4 locations, namely on a aeroplane, on a ship, on a car, at a transit office. I need to have separate entities for these 4 locations because they all have mutiple…
BOOnZ
  • 828
  • 2
  • 15
  • 35
1
vote
2 answers

Should Foreign Keys be used in a structure where multiple options can be selected by a user? If so, how so?

In MySQL, I was advised to store the multiple choice options for "Drugs" as a separate table user_drug where each row is one of the options selected by a particular user. I was also advised to create a 3rd table drug that describes each option…
1
vote
1 answer

SQL: trying to figure out how to use an inner join to combine two separate tables into one

I took a SQL course and am now trying to apply the lessons in practice but I can't seem to find out how to make it work. I have two tables that contain financial information about basketball teams by year. They share the same data in the year and…
1
vote
0 answers

Best practice on referencial integrity failures

I have a Java application that is based (JPA, spring-data) on a relational database (PostgreSQL). This database has several tables referencing a specific table. So referencial integrity kicks in, when the user likes to delete an entry in that…
Sebastian
  • 877
  • 1
  • 9
  • 20
1
vote
2 answers

SQL Relational model links

Can anyone explain the links between the tables? like sometimes there's a bubble, other times a rectangle appears and so on.
Tasbeeh
  • 45
  • 4
1
vote
2 answers

How to get records with different values in same column AND condition on another column

We are trying to get filtered custom field data out of the Moodle database via SQL query. Unfortunately it's necessary to join multiple tables to get the data we need, because Moodle keeps its data this way. Also we can't manipulate the data…
J. Unkrass
  • 730
  • 5
  • 16
1
vote
1 answer

Using `disconnect` to remove relation doesn't type check

I have the following Prisma model definitions: model Pet { id Int @id @default(autoincrement()) name String kind String owner Owner @relation(fields: [ownerId], references: [id]) ownerId Int } model Owner { id Int …
Swen Mulderij
  • 886
  • 2
  • 8
  • 18
1
vote
2 answers

Should I just use a single table?

I have an entity Order. The order has information on date, client, associate who handled order etc. Now the order also needs to store a state i.e. differentiate between won orders and lost orders. The idea is that a customer may submit an…
Cratylus
  • 52,998
  • 69
  • 209
  • 339
1
vote
2 answers

history table and 2nf

Users table and Group users table are history tables (they cannot be moved to archived tables cause that would mess up foreign keys related to those tables. If a group user made a post and left the group, the post should still exist…
firebird
  • 3,461
  • 6
  • 34
  • 45
1
vote
0 answers

Creating two records with Prisma concurrently and connecting them

I have two models, a User and a UserProfile model. When a user registers on my site, it should create a User and User Profile record at the same time. model User { id Int @id @default(autoincrement()) username String @unique…
T. Duke
  • 646
  • 1
  • 6
  • 17
1
vote
1 answer

How can I change the column name of a resulting table from many to many in gorm

I already played a lot with Nestjs using TypeORM and now I'm learning to work with Golang and Gorm. I'm rebuilding a system in Nestjs for Go and I'm experiencing a problem when using many2many relations. As I am working with a database already in…
1
vote
1 answer

How to add an empty migration in prisma?

I need to add an empty migration to write a SQL query and manipulate the data manually. There is no change in my schema and basically, I just need to apply this query to my existing data.
Ali Afsahnoudeh
  • 197
  • 1
  • 3
  • 10
1
vote
1 answer

How to remove relation from django model with ManyToMany field?

How to remove relation from model with ManyToMany field? I've got a model with ManyToManyField relation. I need to remove relation but not data from the following model: class TxHomes(models.Model): user =…
1
vote
0 answers

Using a Transaction between Two different Ports in Hexagonal Architecture

We're using a hexagonal architecture in one of our microservice. Spring Boot is the framework implementing the service. For a use case, we need to update a database table (relational) and send a message to a Kafka topic. Quite usual. We don't want…