Questions tagged [relations]

127 questions
54
votes
2 answers

Is it a bad practice to have several mutually exclusive one-to-one relationships?

Say, a table car has one-to-one relationship to tables electric_car, gas_car, and hybrid_car. If a car is electric_car, it can no longer appear in gas_car or a hybrid_car, etc. Is there anything wrong with such design? Some problems that may occur…
Arthur Tarasov
  • 811
  • 1
  • 9
  • 15
15
votes
1 answer

Database design for products with bundles of products

I am building a database system for my retail business. I have set some tables which are: Product Purchase Sales Balance All are connected one another and are able to show my inventory level. The problem I am having is I also sell bundles of…
shandery
  • 151
  • 1
  • 6
6
votes
1 answer

Structure a database for a Blog

I built a database for a blog. I am a student yet, so my knowledge is limited in this area. I post this question to get a briefly description of what I do wrong, why, and how I can fix it. I'm not a back end developer, so if you misunderstood…
user101258
5
votes
3 answers

Constraining data based on related data in a different table. Should this be done on the database level or the application level?

I am working on a database that contains our customer information as well as information about our vendors. Part of that includes matching our customers with our vendors, the account numbers those vendors provide to us for our customers and what we…
5
votes
3 answers

How do I read ERD Notation (crow's feet) to convert to Natural Language?

Background I am attempting to insure I understand how to read ERD (Entity Relationship Diagram) notation so I can convert it to a natural language explanation. I'm trying to insure I can explain a method of converting what I see in the diagram to…
raddevus
  • 201
  • 1
  • 3
  • 7
5
votes
1 answer

Generate fake data for several tables with relationships

I have 3 tables where I want to generate fake data in UsersCategoryLink. How can I insert in the table UserCategoryLink the column UserID with random users from the table User and a random id from the table Categories. In this SQL fiddle you can see…
H. Pauwelyn
  • 930
  • 6
  • 18
  • 35
4
votes
1 answer

What is the definition of bad circular dependency?

I have been searching for while for a good resource, where the circular dependency is well explained, unfortunately nothing good found. Therefore I tried to understand exactly which kind of circular dependency I should avoid. The problem is I found…
4
votes
1 answer

Mysqldump subset of database with relational data using a master table

I have found a lot of articles describing the concept of exporting and importing relational data, but I have not been able to find any article describing this more generally for a MySQL database, which is why I am creating this question. Problem: I…
4
votes
5 answers

What is the best practice for selecting from two tables with multiple relations?

I have two tables with a structure like below: and am selecting the data with below query: SELECT (SELECT Name FROM Management_EnumerableItem ME WHERE ME.ID = DN) DN, (SELECT Name FROM Management_EnumerableItem ME WHERE ME.ID = PN) PN, (SELECT Name…
4
votes
1 answer

How can I avoid this circular relation?

I based my account/user table design following this article. So I have set my table relationships to look something like this: User <- Memberhip -> Group -> Account With this design, a user is tied to group via a membership table. A group belongs…
Vic
  • 165
  • 1
  • 6
4
votes
1 answer

Unique key based on many-to-many pivot table

I have to manage artists and albums tables: | artists | | albums | | album_artist | +--------------+ +--------------+ +--------------+ | id | | id | | id | | artist | | album | | album_id…
user197675
  • 143
  • 1
  • 3
3
votes
1 answer

How to "merge" rows along with their foreign many-to-many relations without violating unique constraints?

Fiddle: https://dbfiddle.uk/-JLFuIrN Table CREATE TABLE files ( id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text ); CREATE TABLE folders ( id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text ); CREATE TABLE…
3
votes
1 answer

LOB in frequently queried table or separate table

I have a table named FinTrans in an Microsoft SQL Server 2012 server with approx 10K-30K records at any given time and about 2K records are inserted and deleted each day. The table has 3 nvarchar(max) columns that hold possible error messages (3…
Daniel
  • 143
  • 4
3
votes
2 answers

Is the inverse of Armstrong's Axioms valid as well?

I have been looking into Armstrong's axioms a little bit. In a homework[1] exercise I was asked to prove A→G is in F-closure. I managed to get it at this point: AB → GB Being at this point, can I simply say that A → G as it seems pretty…
johndoe123
  • 45
  • 4
3
votes
0 answers

How do you perform the chase test?

Trying to follow the chase algorithm as I understand it, If two rows agree in the left side of a functional dependency (FD for brevity), make their right sides agree too. Always replace a subscripted symbol by the corresponding unsubscripted…
SS'
  • 155
  • 3
  • 5
1
2 3
8 9