rdms

How to retrieve all recursive children of parent row in Oracle SQL?

為{幸葍}努か 提交于 2019-12-02 18:47:36
I've got a recursive query that's really stretching the limits of this Java monkey's SQL knowledge. Now that it's finally 1:30 in the AM, it's probably time to start looking for some help. This is one of the few times Google has failed me. The table is as follows: Parent_ID CHILD_ID QTY 25 26 1 25 27 2 26 28 1 26 29 1 26 30 2 27 31 1 27 32 1 27 33 2 I'm trying to get the following result, where the parent has every child listed below them. Note that the qty's cascade as well. BASE PARENT_ID CHILD_ID QTY 25 25 26 1 25 25 27 2 25 26 28 1 25 26 29 1 25 26 30 1 25 27 31 2 25 27 32 2 25 27 33 4 26

SQL one to one relationship vs. single table

空扰寡人 提交于 2019-11-30 09:05:13
Consider a data structure such as the below where the user has a small number of fixed settings. User [Id] INT IDENTITY NOT NULL, [Name] NVARCHAR(MAX) NOT NULL, [Email] VNARCHAR(2034) NOT NULL UserSettings [SettingA], [SettingB], [SettingC] Is it considered correct to move the user's settings into a separate table, thereby creating a one-to-one relationship with the users table? Does this offer any real advantage over storing it in the same row as the user (the obvious disadvantage being performance). You would normally split tables into two or more 1:1 related tables when the table gets very