Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it bad to use redundant relationships?

Suppose I have the following tables in my database:

tables

Now all my queries depend on Company table. Is it a bad practice to give every other table a (redundant) relationships to the Company table to simplify my sql queries?

Edit 1: Background is a usage problem with a framework. See Django: limiting model data.

Edit 2: No tuple would change his company.

Edit 3: I don't write the mysql queries. I use a abstraction layer (django).

like image 243
svenwltr Avatar asked Jul 27 '10 19:07

svenwltr


People also ask

What is a redundant relationship?

Redundant Relationships These are relationships that are already indicated by other relationships, although not directly. In the case of our example there is a direct relationships between customers and products.

How would you determine if a relationship is redundant?

A relationship is considered redundant when one of the activity successors have this same relationship with a less relationship free float. For example: If activity B is linked FS to activity A. And activity C is linked FS to activity B.

What are the problems caused by redundancy?

Problems caused due to redundancy are: Insertion anomaly, Deletion anomaly, and Updation anomaly. If a student detail has to be inserted whose course is not being decided yet then insertion will not be possible till the time course is decided for student.

Is data redundancy good or bad?

Data redundancy occurs when the same piece of data is stored in two or more separate places, and it's common among businesses and organizations that manage large stores of information. Data redundancy can help protect information from corruption, but it can also cause inaccurate data.


2 Answers

It is bad practice because your redundant data has to be updated independently and therefore redundantly. A process that is fraught with potential for error. (Even automatic cascading has to be assigned and maintained separately)

By introducing this relation you effectively denormalize your database. Denormalization is sometimes necessary for the sake of performance but from your question it sounds like you're just simplifying your SQL.

Use other mechanisms to abstract the complexity of your database: Views, Stored Procs, UDFs

like image 83
Paul Sasik Avatar answered Oct 07 '22 23:10

Paul Sasik


What you are asking is whether to violate Third Normal Form in your design. Doing so is not something to be done without good reason because by creating redundancy you create the possibility for errors and inconsistencies in your data. Also, "simplifying" the model with redundant data to support some operations is likely to complicate other operations. Also, constraints and other data access logic will likely need to be duplicated unnecessarily.

like image 44
nvogel Avatar answered Oct 07 '22 23:10

nvogel