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
18
votes
2 answers

Designing an E-Commerce Database - MySQL

I'm doing an e-commerce project and am confused about the database design for storing products. There are 3 ways I've speculated the database can be made: 1. There can be separate tables for each product category. Table:…
a7omiton
  • 1,597
  • 4
  • 34
  • 61
18
votes
1 answer

Difference between using REFERENCES with and without FOREIGN KEY?

Basically I'd like to know the difference between using REFERENCES with or without a foreign key. I have these 2 examples: CREATE TABLE Employee ( id INT, name VARCHAR(50), birthYear INT, boss INT REFERENCES…
Bluening
  • 195
  • 2
  • 5
17
votes
3 answers

Most elegant approach for writing JSON data to a relational database using Django Models?

I have a typical Relational Database model laid out in Django where a typical model contains some ForeignKeys, some ManyToManyFields, and some fields that extend Django's DateTimeField. I want to save data that I am receiving in JSON format (not…
Optimus
  • 2,716
  • 4
  • 29
  • 49
17
votes
2 answers

Database normalization for School Management System

I am creating system for a school management system and come up with the attached database schema. Following is how the system works: A school has many students and teachers. It has also many courses(subjects) taught. A grade level can have many…
17
votes
5 answers

Best practices for migrating database content from one very poor structure to one very logical?

TL;DR what's the best way to migrate lots of data between one very poorly structured database (with much repetition of columns, no interrelations, and duplicate data), to another highly organised and relational structure? - Sorry about the long…
17
votes
9 answers

How do I help a person who wants relational database data in a CSV format?

The non-technical person who asks, "Can you just put the database in an Excel spreadsheet for me?" is so common it's almost a trope. (I could've sworn there was an xkcd about this, but I can't find it.) We regularly get customers asking for all…
Rich Armstrong
  • 1,432
  • 2
  • 16
  • 20
17
votes
5 answers

MySQL table with a varchar column as foreign key

I am trying to create a table with a varchar column as foreign key but MySql gives me an error while creating the table. My query is like this: CREATE TABLE network_classes ( id TINYINT(1) UNSIGNED NOT NULL AUTO_INCREMENT, category…
Hamid Ghorashi
  • 1,003
  • 3
  • 14
  • 29
17
votes
2 answers

How to store a one to many relation in MySQL database?

I'm making a website and I need to store a random number of data in my database. For example, User john may have one phone number where jack can have 3. I need to be able to store an infinite number of values per user.
Weacked
  • 954
  • 2
  • 7
  • 18
16
votes
1 answer

What's the best way to store an array in a relational database?

I'm currently trying to design a database and I'm not too sure about the best way to approach a dynamically sized array field of one of my objects. My first thought is to use a column in my object to store an array of integers. However the more I…
grundyboy34
  • 372
  • 1
  • 2
  • 9
15
votes
6 answers

disk I/O error with SQLite3 in Python 3 when writing to a database

i am a student just starting out with python, and i was tasked with creating a relational database management system. I think i came pretty far, but i seem to have hit a wall. This is my code: import csv import sqlite3 conn =…
Xander Blaauw
  • 157
  • 1
  • 1
  • 4
15
votes
5 answers

Pros and Cons of Multi-value Databases

I've just started a new job where I'm going to have to do a fair amount of work with a multi-value database (UniVerse). What little database experience I have is in relational databases (SqlServer) and I'm looking for some un-biased information…
Jackson Pope
  • 14,520
  • 6
  • 56
  • 80
15
votes
3 answers

How to understand the 5th Normal Form?

I'm using two online sources for gaining an understanding of the 5NF, without any rigor of Math and proofs. A Simple Guide to Five Normal Forms in Relational Database Theory (by Kent. This one seems to have been reviewed and endorsed in one of his…
Harry
  • 3,684
  • 6
  • 39
  • 48
15
votes
8 answers

Relational Databases and Mathematics?

Can anyone suggest resources that take a mathematical approach to relational databases? Essentially relational algebra I'd guess. I have a mathematics background and now work a great deal with databases and would like to close the gap.
Steve Homer
  • 3,852
  • 2
  • 22
  • 41
15
votes
2 answers

SELECT COUNT across one-to-many relationship

For two tables player and team With a 1-∞ relationship (player to team): how would you count how many players belong to each team? Failed attempt: SELECT team.teamid, (SELECT COUNT(player.team) FROM player) FROM team LEFT JOIN player ON player.team…
Stumbler
  • 2,056
  • 7
  • 35
  • 61
15
votes
3 answers

Inner join with multiple tables

I have these four tables: PRODUCTS --------- PRODUCT_ID PRODUCT_TITLE (other…
Samuel Guimarães
  • 574
  • 3
  • 6
  • 18