database-normalization

Can you move compound keys and/or foreign keys to other tables when normalizing to 3NF (third normal form)

会有一股神秘感。 提交于 2021-02-19 05:18:09
问题 My database design is currently at stage 3NF. The issue that is of concern is the foreign keys and in some cases compound keys. My question is this: Can you move compound keys and/or foreign keys to create other tables provided the attributes associated with the compound keys/foreign keys do not rely on the primary key? I think the answer is yes due to this link: Are Foreign Keys included in Third Normal Form? Best Answer : Just because it's a foreign key doesn't mean it also can't be

Can you move compound keys and/or foreign keys to other tables when normalizing to 3NF (third normal form)

天涯浪子 提交于 2021-02-19 05:17:52
问题 My database design is currently at stage 3NF. The issue that is of concern is the foreign keys and in some cases compound keys. My question is this: Can you move compound keys and/or foreign keys to create other tables provided the attributes associated with the compound keys/foreign keys do not rely on the primary key? I think the answer is yes due to this link: Are Foreign Keys included in Third Normal Form? Best Answer : Just because it's a foreign key doesn't mean it also can't be

Can you move compound keys and/or foreign keys to other tables when normalizing to 3NF (third normal form)

孤人 提交于 2021-02-19 05:17:49
问题 My database design is currently at stage 3NF. The issue that is of concern is the foreign keys and in some cases compound keys. My question is this: Can you move compound keys and/or foreign keys to create other tables provided the attributes associated with the compound keys/foreign keys do not rely on the primary key? I think the answer is yes due to this link: Are Foreign Keys included in Third Normal Form? Best Answer : Just because it's a foreign key doesn't mean it also can't be

Postgres db design Normalize tables or Use Array Columns

亡梦爱人 提交于 2021-02-17 07:03:25
问题 Newbie trying to figure out the best way to design a Postgres db for the following use case scenario. There is an Account table for the business customers and there is a contacts table with a column relationship. account.pk_id, …. contacts.pk_id, contacts.fk_accountid … Thousands of different businesses in the Accounts table will be storing millions of contacts each in the Contacts table. Each contact record will over time belong to between 1 and 100 different categories, lists and products.

Storing “redundant” foreign keys to avoid joins

纵然是瞬间 提交于 2021-02-08 10:13:10
问题 I'm designing a database for a web application project and I came to the conclusion I may have few queries that will require a lot of joined tables to just make one check. I'm wondering how bad is it to store the foreign key somewhere on the way to decrease number of joins required for these queries? To give you an example of what I have at this moment: Service => Booking => Transaction => Wallet => BonusOffer I need to check whether the service has been bought with wallet associated with a

Storing “redundant” foreign keys to avoid joins

纵然是瞬间 提交于 2021-02-08 10:12:27
问题 I'm designing a database for a web application project and I came to the conclusion I may have few queries that will require a lot of joined tables to just make one check. I'm wondering how bad is it to store the foreign key somewhere on the way to decrease number of joins required for these queries? To give you an example of what I have at this moment: Service => Booking => Transaction => Wallet => BonusOffer I need to check whether the service has been bought with wallet associated with a

Functional dependencies in case of nulls

倖福魔咒の 提交于 2021-02-08 09:52:52
问题 Suppose we have a table with 3 columns A,B and C A B C --------------- 1 2 3 2 4 5 4 6 7 n 5 n Here 'n' means null. Can we say that A -> B and A -> C? I know the definition of functional dependencies but I'm just confused in the case of null values. 回答1: If null is considered a value, then the answer is yes. A -> B, C holds in the given data. However, to be a value imposes certain requirements. All operators applicable to the domain (e.g. integers) like equality, addition, less than, and so

If we change a primary key value, why don't we have to change a dependent column value?

折月煮酒 提交于 2021-02-08 08:43:20
问题 I watched one tutorial on youtube about database normalization. The table looks like this: |Item(PK) | Supplier | Supplier Phone | Price| --------------------------------------------- | Xbox One| Microsoft| 1234 | 250 | --------------------------------------------- | PS4 | Sony | 4321 | 300 | --------------------------------------------- | PS Vista| Sony | 4321 | 400 | --------------------------------------------- According to the tutorial this table is in 2NF and every column depends on the

Storing single form table questions in 1 or multiple tables

蓝咒 提交于 2021-01-28 21:17:35
问题 I have been coding ASP.NET forms inside web applications for a long time now. Generally most web apps have a user that logs in, picks a form to fill out and answers questions so your table looks like this Table: tblInspectionForm Fields: inspectionformid (either autoint or guid) userid (user ID who entered it) datestamp (added, modified, whatever) Question1Answer: boolean (maybe a yes/no) Question2Answer: int (maybe foreign key for sub table 1 with dropdown values) Question3Answer: int

How to store a store opening hours in an SQL database?

戏子无情 提交于 2020-12-08 05:11:58
问题 I am developing an app for stores (in fact, restaurants) and need to design the PostgreSQL data structure for it. For instance, the restaurant might have opening hours Mon-Fri from 7:30 to 17:00 and from 20:30 to 1:00 the following day. The data to be stored for each weekday would be something like ['Monday', true, 450, 1050, 1230, 1500 ] , being true === "it does open on Mondays", 450, opening time is 450 minutes past midnight (see here), i.e. at 7:30h, closes at 17:30h, reopens at 20:30h,