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
22
votes
3 answers

How to store bidirectional relationships in a RDBMS like MySQL?

Suppose I want to store relationships among the users of my application, similar to Facebook, per se. That means if A is a friend(or some relation) of B, then B is also a friend of A. To store this relationships I am currently planning to store them…
Ankit
  • 6,772
  • 11
  • 48
  • 84
21
votes
6 answers

NULL permitted in Primary Key - why and in which DBMS?

Further to my question "Why to use ´not null primary key´ in TSQL?"... As I understood from other discussions, some RDBMS (for example SQLite, MySQL) permit "unique" NULL in the primary key. Why is this allowed and how might it be…
20
votes
1 answer

SQLite many-to-many relationship?

I'm trying to set up a SQLite3 database with foos and bars and a many-to-many relation between them. This is what I've got so far: CREATE TABLE foo( id INTEGER PRIMARY KEY NOT NULL, foo_col INTEGER NOT NULL ); CREATE TABLE bar( id…
wes
  • 1,577
  • 1
  • 14
  • 32
20
votes
2 answers

Doctrine - OneToOne Unidirectional vs OneToOne Bidirectional

I joust started playing around with Doctrine ORM library, and Im learning about all associations between tables. So Im stuck with differences in Unidirectional and Bidirectional relation. As I get it, Unidirectional relation has primary key only on…
otporan
  • 1,345
  • 2
  • 12
  • 29
19
votes
3 answers

Adding constraints in phpMyAdmin

I feel like I'm being stupid, but I can't find anywhere on the phpMyAdmin interface to add constraints to foreign keys e.g. CASCADE ON DELETE I've looked for similar questions on here and on the phpMyAdmin wiki but I can't find anything about it. I…
Alex
  • 5,364
  • 9
  • 54
  • 69
19
votes
2 answers

Pizza & Food - database design

I want to create a website that allow customer to order food from the website. There are two food type: regular food/drink (eg: burger, donner kebab, chip, coke, pepsi etc) Pizza food (eg: Margherita Pizza, meat Pizza, etc) If they select pizza…
I'll-Be-Back
  • 10,530
  • 37
  • 110
  • 213
19
votes
3 answers

Relational vs Non-Relational Data Modeling

I have a user database with the following properties for each user: user id name zip city In a relational database I would model it in a table user: user id name location_id and have a second table called location: location id zip city and…
19
votes
1 answer

SqlAlchemy - Filtering by field defined as a ForeignKey

I am trying to get instances of a class filtered by a field which is a foreign key but when I try to do that, I always get all the entries in the database, instead of the ones that match the criterion. Let's say I have a couple of classes using…
Savir
  • 17,568
  • 15
  • 82
  • 136
19
votes
3 answers

Algebra Relational sql GROUP BY SORT BY ORDER BY

I wanted to know what is the equivalent in GROUP BY, SORT BY and ORDER BY in algebra relational ?
Cyberflow
  • 1,255
  • 5
  • 14
  • 24
18
votes
1 answer

What's the real difference between Alternate Key and HasIndex with uniqueness in EF core?

I'm intrested in what is the real difference between this e.HasIndex(c => new { c.UserId, c.ApplicationId, c.Value }).IsUnique(); and this e.HasAlternateKey(c => new { c.UserId, c.ApplicationId, c.Value }); in EF core fluent api configuration. The…
Menyus
  • 6,633
  • 4
  • 16
  • 36
18
votes
9 answers

What's the point of a candidate key?

I'm fairly new to database management and this question never seems to be answered in more than one sentence. All other SO answers say "A candidate key is a minimal super key." That means nothing to me. A candidate key is supposed to specify…
18
votes
3 answers

What is the difference between an elastic search index and an index in a relational database?

It seems that in elastic search you would define an index on a collection, whereas in a relational DB you would define your index on a column. If the entire collection is indexed, why does it need to be defined?
Musical Shore
  • 1,361
  • 3
  • 20
  • 41
18
votes
4 answers

Why are key value pair noSQL db's faster than traditional relational DBs

It has been recommended to me that I investigate Key/Value pair data systems to replace a relational database I have been using. What I am not quite understanding is how this improves efficiency of queries. From what I understand you are going to be…
Ankur
  • 50,282
  • 110
  • 242
  • 312
18
votes
5 answers

Do graph databases deprecate relational databases?

I'm new to DBs of any kind. It seems you can represent any relational database in graph form (although it might be a very flat graph), and any graph database in a relational database (with enough tables). A graph can avoid a lot of lookups in other…
David
  • 27,652
  • 18
  • 89
  • 138
18
votes
3 answers

One-to-Many relationship in MySQL - how to build model?

I have got two tables: 1) Area 2) Map Each Area shall have at least 1 Map, but can also have more than one Map. One Map can only belong to one Area. How to build this in MySQL?
tellob
  • 1,220
  • 3
  • 16
  • 32