Consider the following three tables where keys are underlined: Graphs(graphid, graphname), Nodes(nodeid, nodename, nodeweight, graphid), Edges(parentid, childid, edgeweight, graphid), formulate a SQL statement for each query in the following.
8. Return all graphids of those graphs such that every edge has a different weight.
8.SELECT graphid FROM Graphs
WHERE graphid NOT IN
(SELECT graphid FROM
(SELECT edgeweight,graphid,COUNT(edgeweight) FROM
Edges GROUP BY graphid,edgeweight
HAVING COUNT(edgeweight) >1));
EXPLANATION:-
Here, we are using SELECT to fetch data from the table.
Also, we are using sub query .In sub query we are getting result as list of graphid which are having two or more edges with same edgeweight.
Here, in sub query we are using COUNT() aggregate function to get the count of such edges.
Then, we are using GROUP BY to get the result for each graph and edgeweight.
HAVING clause is used with aggregate function to check for count to be greater than 1.
In main query we are getting all the graphids which are not in the list produced by sub query.
Consider the following three tables where keys are underlined: Graphs(graphid, graphname), Nodes(nodeid, nodename, nodeweight, graphid), Edges(parentid,...
Consider the following three tables where keys are underlined: Graphs(graphid, graphname), Nodes(nodeid, nodename, nodeweight, graphid), Edges(parentid, childid, edgeweight, graphid), formulate a SQL statement for each query in the following. 1. Return the graphids of those graphs in which every exit node has a different weight.
Consider the following three tables where keys are underlined: Graphs(graphid, graphname), Nodes(nodeid, nodename, nodeweight, graphid), Edges(parentid, childid, edgeweight, graphid), formulate a SQL statement for each query in the following. 5. Return all graphids of those graphs in which every node is the child of all other nodes.
Consider the following three tables where keys are underlined: Graphs(graphid, graphname), Nodes(nodeid, nodename, nodeweight, graphid), Edges(parentid, childid, edgeweight, graphid), formulate a SQL statement for each query in the following. 9. Return all graphids of those graphs such that every entry node is also a fork node.
Consider the following three tables where keys are underlined: Graphs(graphid, graphname), Nodes(nodeid, nodename, nodeweight, graphid), Edges(parentid, childid, edgeweight, graphid), formulate a SQL statement for each query in the following. 6. Return all graphids of those graphs that have some fork nodes but no join nodes.
Consider the following three tables where keys are underlined: Graphs(graphid, graphname), Nodes(nodeid, nodename, nodeweight, graphid), Edges(parentid, childid, edgeweight, graphid), formulate a SQL statement for each query in the following. 7. Return all graphids of those graphs such that the graph has at least 1 node that is not connected to any other nodes (i.e. neither as a parent nor as a child).
Consider the following three tables where keys are underlined: Graphs(graphid, graphname), Nodes(nodeid, nodename, nodeweight, graphid), Edges(parentid, childid, edgeweight, graphid), formulate a SQL statement for each query in the following. 2. Assume each node has a different weight, return the nodeids of the top three nodes that have the highest weight for the graph with graphid = 1234.
Consider the following three tables where keys are underlined: Graphs(graphid, graphname), Nodes(nodeid, nodename, nodeweight, graphid), Edges(parentid, childid, edgeweight, graphid), formulate a SQL statement for each query in the following. 3. Suppose there is a node X in graph with graphid = 1234 such that all other nodes are the parents of node X. Return the nodeid of node X.