database-normalization

How far to take normalization?

江枫思渺然 提交于 2019-11-27 18:35:21
I have these tables: Projects(projectID, CreatedByID) Employees(empID,depID) Departments(depID,OfficeID) Offices(officeID) CreatedByID is a foreign key for Employees . I have a query that runs for almost every page load. Is it bad practice to just add a redundant OfficeID column to Projects to eliminate the three joins? Or should I do the following: SELECT * FROM Projects P JOIN Employees E ON P.CreatedBY = E.EmpID JOIN Departments D ON E.DepID = D.DepID JOIN Offices O ON D.officeID = O.officeID WHERE O.officeID = @SomeOfficeID In application programming I "Write with best practices first and

First-time database design: am I overengineering? [closed]

我的未来我决定 提交于 2019-11-27 16:34:11
Background I'm a first year CS student and I work part time for my dad's small business. I don't have any experience in real world application development. I have written scripts in Python, some coursework in C, but nothing like this. My dad has a small training business and currently all classes are scheduled, recorded and followed up via an external web application. There is an export/"reports" feature but it is very generic and we need specific reports. We don't have access to the actual database to run the queries. I've been asked to set up a custom reporting system. My idea is to create

normalization in database

試著忘記壹切 提交于 2019-11-27 15:53:51
I have one table. How can I normalize this. Good question given your data set. Keep in mind the whole point of normalization is to reduce duplication. 3NF is often the best way to go. But given my experience I've found very little benefit to pulling a repeated value out into a different table if it will be the only value in that table. Take for example your most duplicated column, emp_type. If you were to normalize it into a separate table , it would look like this: Emp_Type_Id | Emp_type ------------------------ 1 | Manager 2 | Engineer 3 | Tech Support And your current table would look like:

Decision between storing lookup table id's or pure data

早过忘川 提交于 2019-11-27 10:58:36
问题 I find this comes up a lot, and I'm not sure the best way to approach it. The question I have is how to make the decision between using foreign keys to lookup tables, or using lookup table values directly in the tables requesting it, avoiding the lookup table relationship completely. Points to keep in mind: With the second method you would need to do mass updates to all records referencing the data if it is changed in the lookup table. This is focused more towards tables that have a lot of

What is combining repeating sets of row information into new entities called when doing database normalization?

本小妞迷上赌 提交于 2019-11-27 09:39:27
I'm a bit confused about a certain piece of database normalization and thought I'd ask StackOverflow: Imagine you have the following relations that relate products to colors. Notice that Product 1 and Product 2 both use the same set of colors (Blue and Green). Product_Color Color +-------------+-------------+ +-------------+-------------+ | Product* | Color* | | ColorId* | Name | +-------------+-------------+ +-------------+-------------+ | 1 | 1 | | 1 | Blue | | 1 | 2 | | 2 | Green | | 2 | 1 | +-------------+-------------+ | 2 | 2 | +-------------+-------------+ If I create two new relations,

What is the minimal proof that a database relation is not in BCNF?

我的未来我决定 提交于 2019-11-27 07:18:51
问题 I have the following functional dependencies (they represent all the functional dependencies on my relation): (1) BrokerName -> Office (2) StockName -> Dividend (3) InvestorId -> BrokerName (4) InvestorId, Stockname -> Quantity (5) InvestorId, Stockname -> Office I know from using the techniques in this YouTube video that (InvestorId, Stockname) is my one and only candidate key. According to @nvogel's solution in this SO thread: A relation, R, is in BCNF iff for every nontrivial FD (X->A)

Elegant normalization without adding fields, extra table. Best relationship

半城伤御伤魂 提交于 2019-11-27 04:54:55
问题 I have 2 tables I am trying to normalize. The problem is I don't want to create an offhand table with new fields, though a link table perhaps works. What is the most elegant way to convey that the "Nintendo" entry is BOTH a publisher and a developer? I don't want "Nintendo" to be duplicated. I am thinking a many-to-many relationship can be key here. I want to stress that I absolutely want the developer and a publisher tables to remain. I don't mind creating a link between the 2 with a new

How far to take normalization?

孤者浪人 提交于 2019-11-27 04:18:49
问题 I have these tables: Projects(projectID, CreatedByID) Employees(empID,depID) Departments(depID,OfficeID) Offices(officeID) CreatedByID is a foreign key for Employees . I have a query that runs for almost every page load. Is it bad practice to just add a redundant OfficeID column to Projects to eliminate the three joins? Or should I do the following: SELECT * FROM Projects P JOIN Employees E ON P.CreatedBY = E.EmpID JOIN Departments D ON E.DepID = D.DepID JOIN Offices O ON D.officeID = O

Native JSON support in MYSQL 5.7 : what are the pros and cons of JSON data type in MYSQL?

你说的曾经没有我的故事 提交于 2019-11-27 03:02:21
In MySQL 5.7 a new data type for storing JSON data in MySQL tables has been added. It will obviously be a great change in MySQL. They listed some benefits Document Validation - Only valid JSON documents can be stored in a JSON column, so you get automatic validation of your data. Efficient Access - More importantly, when you store a JSON document in a JSON column, it is not stored as a plain text value. Instead, it is stored in an optimized binary format that allows for quicker access to object members and array elements. Performance - Improve your query performance by creating indexes on

Minimum no of tables that exists after decomposing relation R into 1NF?

余生长醉 提交于 2019-11-27 02:13:01
Consider the relation R(A, B, C, D, E, F, G) with the following types of attributes:- Total No of Keys = 1 = {A} Set of Simple (or) Atomic (or) Single Valued Attributes = {B, C} Set of Multivalued Attributes = {D, E} Set of Composite Attributes = { F, G} What would be the minimum no of tables that exists after decomposing relation R into 1NF? (A) 3 (B) 2 (C) 4 (D) 5 My attempt: We needed different table for each multivalued attributes with given key(A), total = 2 Similarly, we needed different table for each composite attributes, total = 2. There are total 4 such attribute. I give 4 tables