Entity Relationship (ER) Diagram enum values - class

As far as I know, we can show enum values in Class Diagrams as shown below:
----------------------+
| <<enumeration>> |
| DayOfTheWeek |
|_____________________|
| Sunday |
| Monday |
| Tuesday |
| ... |
+---------------------+
+---------------------+
| Event |
|_____________________|
| day : DayOfTheWeek |
| ... |
+---------------------+
However, I cannot find any representation for showing enum values in ER Diagrams. So, how to show enum in ER Diagrams with the proper relation types?

Related

Tableau - How check if a value equals a value from another row and column

I have the following table:
+------------+--------------+---------+---------+---------+
| Category | Subcategory |FruitName| Date1 | Date2 |
+------------+--------------+---------+---------+---------+
| A | 1 | Foo | 2011 | 2017 |
| | +---------+---------+---------+
| | |Pineapple| 2011 | 2013 |
| | +---------+---------+---------+
| | | Apple | 2017 | 2018 |
| +--------------+---------+---------+---------+
| | 2 | Peach | 2014 | 2015 |
| | +---------+---------+---------+
| | | Orange | 2015 | 2018 |
| | +---------+---------+---------+
| | | Banana | 2009 | 2013 |
+------------+--------------+---------+---------+---------+
I'd like to display the fruit names where Date1 from one row == Date2 from another row, but only if they are equals within the same Subcategory. In the table above, this filter should retrieve the rows based on those criterias:
And the final table would look like this:
+------------+--------------+---------+---------+---------+
| Category | Subcategory |FruitName| Date1 | Date2 |
+------------+--------------+---------+---------+---------+
| A | 1 | Foo | 2011 | 2017 |
| | +---------+---------+---------+
| | | Apple | 2017 | 2018 |
| +--------------+---------+---------+---------+
| | 2 | Peach | 2014 | 2015 |
| | +---------+---------+---------+
| | | Orange | 2015 | 2018 |
+------------+--------------+---------+---------+---------+
How can I possibly achieve this?
Your logic provided doesnot match with the output provided. If you are after the output, your logic should be:
SELECT f1.* from fruits f1 JOIN fruits f2
ON f1.Subcategory=f2.Subcategory
WHERE f1.Date1=f2.Date2 OR f1.Date2 = f2.Date1;
If your data source supports custom SQL, you can straight away use the above query. If not you can still achieve it in Tableau using a Full Outer Join and a calculated Field.(Tableau doesn't support OR condition in Joins.)
Create a self full outerjoin with the following criteria
Create a calculation called 'FILTER' as below
Apply a datasource filter to keep only 'FILTER' = True
Hide Fields from the rightside connection and you will have the required output.

Sumif in Postgresql between two tables

These are my two sample tables.
table "outage" (column formats are text, timestamp, timestamp)
+-------------------+----------------+----------------+
| outage_request_id | actual_start | actual_end |
+-------------------+----------------+----------------+
| 1-07697685 | 4/8/2015 4:48 | 4/8/2015 9:02 |
| 1-07223444 | 7/17/2015 4:24 | 8/01/2015 9:23 |
| 1-07223450 | 2/13/2015 4:24 | 4/29/2015 1:03 |
| 1-07223669 | 4/28/2017 9:20 | 4/30/2017 6:58 |
| 1-08985319 | 8/24/2015 3:18 | 8/24/2015 8:27 |
+-------------------+----------------+----------------+
and a second table "prices" (column format is numeric, timestamp)
+-------+---------------+
| price | stamp |
+-------+---------------+
| -2.31 | 2/1/2018 3:00 |
| -2.35 | 2/1/2018 4:00 |
| -1.77 | 2/1/2018 5:00 |
| -2.96 | 2/1/2018 6:00 |
| -5.14 | 2/1/2018 7:00 |
+-------+---------------+
My Goal: To sum the prices in between the start and stop times of each outage_request_id.
I have no idea how to go about properly joining the tables and getting a sum of prices in those outage timestamp ranges.
I can't promise this is efficient (in fact for very large tables I feel pretty confident it's not), but this should notionally get you what you want:
select
o.outage_request_id, o.actual_start, o.actual_end,
sum (p.price) as total_price
from
outage o
left join prices p on
p.stamp between o.actual_start and o.actual_end
group by
o.outage_request_id, o.actual_start, o.actual_end

Tableau - Calculated field for difference between date and maximum date in table

I have the following table that I have loaded in Tableau (It has only one column CreatedOnDate)
+-----------------+
| CreatedOnDate |
+-----------------+
| 1/1/2016 |
| 1/2/2016 |
| 1/3/2016 |
| 1/4/2016 |
| 1/5/2016 |
| 1/6/2016 |
| 1/7/2016 |
| 1/8/2016 |
| 1/9/2016 |
| 1/10/2016 |
| 1/11/2016 |
| 1/12/2016 |
| 1/13/2016 |
| 1/14/2016 |
+-----------------+
I want to be able to find the maximum date in the table, compare it with every date in the table and get the difference in days. For the above table, the maximum date in table is 1/14/2016. Every date is compared to 1/14/2016 to find the difference.
Expected Output
+-----------------+------------+
| CreatedOnDate | Difference |
+-----------------+------------+
| 1/1/2016 | 13 |
| 1/2/2016 | 12 |
| 1/3/2016 | 11 |
| 1/4/2016 | 10 |
| 1/5/2016 | 9 |
| 1/6/2016 | 8 |
| 1/7/2016 | 7 |
| 1/8/2016 | 6 |
| 1/9/2016 | 5 |
| 1/10/2016 | 4 |
| 1/11/2016 | 3 |
| 1/12/2016 | 2 |
| 1/13/2016 | 1 |
| 1/14/2016 | 0 |
+-----------------+------------+
My goal is to create this Difference calculated field. I am struggling to find a way to do this using DATEDIFF.
And help would be appreciated!!
woodhead92, this approach would work, but means you have to use table calculations. Much more flexible approach (available since v8) is Level of Details expressions:
First, define a MAX date for the whole dataset with this calculated field called MaxDate LOD:
{FIXED : MAX(CreatedOnDate) }
This will always calculate the maximum date on table (will overwrite filters as well, if you need to reflect them, make sure you add them to context.
Then you can use pretty much the same calculated field, but no need for ATTR or Table Calculations:
DATEDIFF('day', [CreatedOnDate], [MaxDate LOD])
Hope this helps!

Tableau to create single chart from multiple parameters

I have tableau workbook online
Before, I had filter for single Principal, and applied to all CUSIPs, and I was able to plot all the inflation-adjusted principals based on Index ratios for a particular date, (refer tab Inflation-Adjusted Trend) i.e.
Now, I have multiple filters based on multiple Principals, i.e. buy one CUSIP for $1500, buy another for $900, etc (refer tab Infl-Adjusted Trend 2)
These were the columns and rows
But I do not like the format of this graph.
I wish to have all the lines together in one graph, just like the single-principal tab below ..... how to fix this? How to bring all the values into one chart?
You currently have six calculated fields calculating your inflation-adjusted principals, one for each CUSIP. Here's what that table might end up looking like:
+-----------+-------------+-------------+-------------+-------------+-----+
| CUSIP | 912828H45 P | 912828NM8 P | 912828PP9 P | 912828QV5 P | ... |
+-----------+-------------+-------------+-------------+-------------+-----+
| 912828H45 | $100 | NULL | NULL | NULL | ... |
| 912828NM8 | NULL | $455 | NULL | NULL | ... |
| 912828PP9 | NULL | NULL | $132 | NULL | ... |
| 912828QV5 | NULL | NULL | NULL | $553 | ... |
| ... | ... | ... | ... | ... | ... |
+-----------+-------------+-------------+-------------+-------------+-----|
There's definitely a better way. Your fields are set up like this:
IF [Cusip] = "912828H45"
THEN
[912828H45 Principal] * [Index Ratio]
END
Instead of setting up one field per CUSIP, make a single field that calculates that value for each CUSIP.
IF [Cusip] = "912828H45"
THEN
[912828H45 Principal] * [Index Ratio]
ELSEIF [Cusip] = "912828NM8"
THEN
[912828NM8 Principal] * [Index Ratio]
...
END
Now your table looks like this.
+-----------+------------------------------+-----+
| CUSIP | Inflation-Adjusted Principal | ... |
+-----------+------------------------------+-----+
| 912828H45 | $100 | ... |
| 912828NM8 | $455 | ... |
| 912828PP9 | $132 | ... |
| 912828QV5 | $553 | ... |
| ... | ... | ... |
+-----------+------------------------------+-----+
That's a LOT easier to work with. Drag that single field into Rows and color by [Cusip].

UML class diagram enum

I am modeling a class diagram. An attribute of a class is an enumeration. How do I model this? Normally you do something like this:
- name : string
But how does one do this with an enum?
They are simply showed like this:
_______________________
| <<enumeration>> |
| DaysOfTheWeek |
|_____________________|
| Sunday |
| Monday |
| Tuesday |
| ... |
|_____________________|
And then just have an association between that and your class.
If your UML modeling tool has support for specifying an Enumeration, you should use that. It will likely be easier to do and it will give your model stronger semantics. Visually the result will be very similar to a Class with an <<enumeration>> Stereotype, but in the UML metamodel, an Enumeration is actually a separate (meta)type.
+---------------------+
| <<enumeration>> |
| DayOfTheWeek |
|_____________________|
| Sunday |
| Monday |
| Tuesday |
| ... |
+---------------------+
Once it is defined, you can use it as the type of an Attribute just like you would a Datatype or the name one of your own Classes.
+---------------------+
| Event |
|_____________________|
| day : DayOfTheWeek |
| ... |
+---------------------+
If you're using ArgoEclipse or ArgoUML, there's a pulldown menu on the toolbar which selects among Datatype, Enumeration, Signal, etc that will allow you to create your own Enumerations. The compartment that normally contains Attributes can then be populated with EnumerationLiterals for the values of your enumeration.
Here's a picture of a slightly different example in ArgoUML:
Typically you model the enum itself as a class with the enum stereotype