AB →→ C already in fourth normal form - sql

Consider the following set of functional dependencies on the relation schema R = (A, B, C, D, E). Decompose the relation into a collection of relation schemas in 4NF. Provide detailed information of the decomposition process.
AB →→ C
B → D
A → E
If you start from the top with AB →→ C, doesn't that fit 4nf and you are done?

Related

SQL: Finding all members of a group when they are only listed in pairs, and not all pairs are listed

I have some data that looks like this, and identifies pairs that are related:
From_ID To_ID
A C
B C
D E
E D (note this is the same pair as above, in a different order)
E F
A F
G H
Using the logic of 'if x is paired with y, and y is paired with z, then x is paired with z', how can I run an SQL query to return all members of a group?
So for the table above I would like a set of results that identifies or returns two groups: 'A, B, C, D, E, F' and 'G, H', not fussy about how this is done.
It feels like some kind of iterative query but I really have no idea where to start with this so any pointers would be appreciated.
edit: could be run in SQL Developer or HiveQL.

Unwind to another brach of segues in swift or Objective-C

I have a scenario like this:
/-> C -> D \
A -> B - -> G (Contain values of D and F,
\-> E -> F /
Basically at G I have a list of value produce by D and F, let us call D1 and F1.
To create a new value from G, I have to just unwind to B and user can either choose branch C or E and continue to the end G with value of D2 or F2, or he can pop back to A. Let us say the new value is F2, though ABEFG
Now I'm facing a problem, that is I want to edit the values at G, let us say D1.
I want to be able to pop back to D but also allow users pop back to C etc, but D is not in the workflow ABEFG.
My guess is that I have to back up to B and somehow prepare multiple segues up to D but I have no idea if this kind of workflow exists.
Apparently, there is no such way. The solution I found is
Find the instance of B in navigationController!.viewControllers
popToViewController B
Initiate C & D from Main storyboard with identifier (they are already deallocated anyway)
Setup some properties of C & D from D1
pushViewController C & D

Optaplanner: Vehicle Routing – order of precedence while visiting cities

Suppose that you have a car that is required to visit cities A, B, C, D and E in the shortest possible time or distance. But there is order of precedence in which these cities can be visited. For e.g., B must be visited first before you visit “A,” and “E” must be visited first before you can visit “C.” So all of the following solutions are valid:
Car -> B, D, E, A, C
Or
Car -> D, E, B, A, C
Or
Car -> E, B, A, D, C
Following routes will be invalid:
Car -> A, B, D, E, C (Constraint violated since B must be visited first before you can visit A)
Or
Car -> B, D, A, C, E (Constraint violated since E must be visited first before you can visit C)
In Optaplanner, is there any way to enforce such constraints? I think this has to be done while forming a chain. The default chain might have to be manually revisited to enforce such a constraint. But I don’t know how. Any pointers will be greatly appreciated.
Vikas
Introduce a shadow variable that keeps the chainIndex in a chain of a vehicles.
For example: Vehicle A starts in Brussels then goes to Paris then to London. Vehicle B starts in Brussels then goes to Berlin and then to Prague. Then it works like this:
Paris's anchor is A and its chainIndex is 1.
London's anchor is A and its chainIndex is 2.
Berlin's anchor is B and its chainIndex is 1.
Prague's anchor is B and its chainIndex is 2.
Adding your constraint by using that chainIndex and the anchor is then trivial.

Arrange numbers in order

I've some variables, Lets say a, b, c, d. All belongs to a fixed interval [0, e]
Now i've some relations between them like
a > b
a > c
b > d
Something like this; I want to make a function which print all the possible cases for this.
Example:
a b c d
a c b d
a b d c
a c b d
In essence, what you have is a directed acyclic graph.
A relatively simple approach is to store, for each variable, a set of the variables that must precede them. (In your example, this storage would map b to {a}, c to {a}, and d to {b}.) You can then write a recursive function that generates all valid tails consisting of a subset of these variables (in your case, for example, the subset {c,d} produces two valid tails: [c,d] and [d,c]). This recursive function examines each variable in the subset and determines whether its prerequisites are already met. (For example, since b maps to {a}, any subset including both a and b cannot produce a tail that begins with b.) If so, then it can recursively call itself on the subset excluding that variable.
There are some optimizations you can then perform, if desired. For example, you can use dynamic programming to avoid repeatedly re-computing the set of valid tails for the same subset.

Oracle Spatial: how to query all polygons what are connected (recursivelly)?

Let's say we have 6 polygons ( A,B,C,D,E, F)in Spatial database.
A touches B,
B touches C and D,
E and F are not connected to other polygons.
A - B
/ \
C D E F
Having Polygon A, I need to query all polygons connected to it , and do it "recursivelly" Cannot describe it better. So the query by A should return A, B, C, D.
Of course, it is possible to do programmatically, first using SDO_RELATE query B by A, and then query C and D by B. But is it possible to do the task with a single query?