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
31
votes
1 answer

Will multiple calls to `now()` in a single PostgreSQL query always give the same result?

I want to insert one row in a table; e.g.: INSERT INTO some_table VALUES (now(), now()); I want the date value in both the columns to be equal. Is the above query safe for this requirement? Or should I use other alternatives like…
Vikas Prasad
  • 3,163
  • 5
  • 28
  • 39
31
votes
5 answers

Closest equivalent to SQLAlchemy for Java/Scala

As someone unfamiliar with Python, I've often heard a lot of praise for SQLAlchemy. So I'd like to understand: What does it offer compared to "type-safe SQL builders" like jOOQ or QueryDSL? Are there closer equivalents to it in Java (or Scala)…
Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
30
votes
4 answers

How to empty my destination table before inserting new records in SSIS?

I use SSIS to generate and transform new data for later use in a new system. I have a problem every time I run my SSIS Package, it keeps inserting new records to my destination tables. How can I empty my destination table (/OLE DB Destination)…
Tassisto
  • 9,877
  • 28
  • 100
  • 157
29
votes
3 answers

Is it OK to name a MySQL index the same as the column it indexes?

Is it considered bad form to give an index the same name as the column it is based on? Like if you have a column named 'foo' and you want to create a normal index on it, would it be okay to name the index 'foo'? MySQL doesn't complain, but I am…
sqlman
  • 631
  • 1
  • 7
  • 8
29
votes
2 answers

How to structure and query an appointment system based on time slots where each bookable entity has a different time table daily?

I'm developing a lawyer booking system, where a person can book an appointment at a given time in a given day (the next lawyer's available day). Let's say it is a ZocDoc for lawyers. The same structure, with appointments based on time:…
AlfredBaudisch
  • 760
  • 1
  • 11
  • 20
28
votes
8 answers

Are document-oriented databases meant to replace relational databases?

Recently I've been working a little with MongoDB and I have to say I really like it. However it is a completely different type of database then I am used. I've noticed that it is most definitely better for certain types of data, however for…
tplaner
  • 8,363
  • 3
  • 31
  • 47
28
votes
3 answers

Can't get Laravel associate to work

I'm not quite sure if I understand the associate method in Laravel. I understand the idea, but I can't seem to get it to work. With this (distilled) code: class User { public function customer() { return $this->hasOne('Customer'); …
Matthijn
  • 3,126
  • 9
  • 46
  • 69
26
votes
8 answers

What are the reasons *not* to use a GUID for a primary key?

Whenever I design a database I automatically start with an auto-generating GUID primary key for each of my tables (excepting look-up tables) I know I'll never lose sleep over duplicate keys, merging tables, etc. To me it just makes sense…
Yarin
  • 173,523
  • 149
  • 402
  • 512
25
votes
2 answers

how much data can a 5MB SQL database store?

I'm interested in using Heroku for my project. I'm not interested in paying for it at the moment but the free plan only offers a 5MB database. Is there any measure I can use to know how many columns/rows of simple text data can be stored in a 5MB…
donald
  • 23,587
  • 42
  • 142
  • 223
25
votes
2 answers

Why does referencing a SQLite rowid cause foreign key mismatch?

SQLite version 3.7.9 2011-11-01 00:52:41 sqlite> PRAGMA foreign_keys = 1; sqlite> CREATE TABLE foo(name); sqlite> CREATE TABLE bar(foo_rowid REFERENCES foo(rowid)); sqlite> INSERT INTO foo VALUES('baz'); sqlite> SELECT rowid, name FROM…
Jordan
  • 4,510
  • 7
  • 34
  • 42
25
votes
4 answers

One-to many relationships in ER diagram

I am trying to show the following in the ER diagram: There are instructors and courses, a course is taught by only one instructor whereas an instructor can give many courses. My question is, is there any difference between two diagrams, in other…
yrazlik
  • 10,411
  • 33
  • 99
  • 165
24
votes
3 answers

Do stored procedures run in database transaction in Postgres?

If a stored procedure fails in middle, are changes at that point from the beginning of SP rolled back implicitly or do we have to write any explicit code to make sure that SP runs in a database transaction only?
24
votes
4 answers

Representing Sparse Data in PostgreSQL

What's the best way to represent a sparse data matrix in PostgreSQL? The two obvious methods I see are: Store data in a single a table with a separate column for every conceivable feature (potentially millions), but with a default value of NULL for…
Cerin
  • 60,957
  • 96
  • 316
  • 522
23
votes
1 answer

Searching by related fields in django admin

I've been looking at the docs for search_fields in django admin in the attempt to allow searching of related fields. So, here are some of my models. # models.py class Team(models.Model): name = models.CharField(max_length=255) class…
markwalker_
  • 12,078
  • 7
  • 62
  • 99
22
votes
3 answers

Natural join if no common attributes

What will natural join return in relational algebra if tables don't have attributes with same names? Will it be null or the same as cross join (cross product) (Cartesian product)?