UML class diagram enum - class

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

Related

Entity Relationship (ER) Diagram enum values

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?

How to represent repeating month in ISO 8601

I try to promote the usage of ISO8601. How can every month of any year and halves of theses months be representated in ISO 8601?
We use a perpetual calendar in Excel where there are 2 column headers : first row is January, February, etc. and below a column subdivided into 2, something like this following example:
| Tasks | January | February | March | ...
| | | | | | | | ...
| task1 | | X | | X | | | ...
| task2 | | | X | | | | ...
How to best merge these header rows into in a meaningful row, written Jan-<first half> | Jan-<second-half> | etc. in an easily readable form. I think January-01 | January-02 is obviously not the answer. If this is not the right way to do it, please, describe how to deal with this kind of repetition.
This question is different from the one about representing date ranges I've redirected to as in the later start and end years/dates are indicated. My question is about recurring approximate date spans.
Thanks

Combine multiple rows into single row in Google Data Prep

I have a table which has multiple payload values in separate rows. I want to combine those rows into a single row to have all the data together. Table looks something like this.
+------------+--------------+------+----+----+----+----+
| Date | Time | User | D1 | D2 | D3 | D4 |
+------------+--------------+------+----+----+----+----+
| 2020-04-15 | 05:39:45 UTC | A | 2 | | | |
| 2020-04-15 | 05:39:45 UTC | A | | 5 | | |
| 2020-04-15 | 05:39:45 UTC | A | | | 8 | |
| 2020-04-15 | 05:39:45 UTC | A | | | | 7 |
+------------+--------------+------+----+----+----+----+
And I want to convert it to something like this.
+------------+--------------+------+----+----+----+----+
| Date | Time | User | D1 | D2 | D3 | D4 |
+------------+--------------+------+----+----+----+----+
| 2020-04-15 | 05:39:45 UTC | A | 2 | 5 | 8 | 7 |
+------------+--------------+------+----+----+----+----+
I tried "set" and "aggregate" but they didn't work as I wanted them to and I am not sure how to go forward.
Any help would be appreciated.
Thanks.
tl;dr:
use fill() function to fill all empty values within each d1-d4 columns in the wanted group (AKA - the columns date+time+user) then dedup\aggregate to your heart's content.
long version
So the quickest way to do this is by using a window-function called "fill()".
What this function does for each given field in a column, it tells it:
"Look down. look up. find the closest non-empty value, and copy it!"
you can ofcourse limit it's sight (look only 3 rows above, for example) but for this example, don't need the limitation. so your fill function will look like this:
FILL($col, -1, -1)
So the "$col" will reference all the chosen columns. the "-1" says "unlimited sight".
finally, the "~" says "from column D1 to column D4".
So, function will look like this:
.
Which in turn will make your columns look like this:
.
Now you can use the "dedup" transformation to remove any duplications, and only 1 copy of each "group" will remain.
Alternatively, if you still want to use "group by", you can do that aswell.
Hope this helps =]
p.s
There are more ways to do this - which entails using the "pivot" transformation, and array unnesting. But in the process you'll lose your columns' names, and will need to rename them.

SQL parameter table

I suspect this question is already well-answered but perhaps due to limited SQL vocabulary I have not managed to find what I need. I have a database with many code:description mappings in a single 'parameter' table. I would like to define a query or procedure to return the descriptions for all (or an arbitrary list of) coded values in a given 'content' table with their descriptions from the parameter table. I don't want to alter the original data, I just want to display friendly results.
Is there a standard way to do this?
Can it be accomplished with SELECT or are other statements required?
Here is a sample query for a single coded field:
SELECT TOP (5)
newid() as id,
B.BRIDGE_STATUS,
P.SHORTDESC
FROM
BRIDGE B
LEFT JOIN PARAMTRS P ON P.TABLE_NAME = 'BRIDGE'
AND P.FIELD_NAME = 'BRIDGE_STATUS'
AND P.PARMVALUE = B.BRIDGE_STATUS
ORDER BY
id
I want to produce 'decoded' results like:
| id | BRIDGE_STATUS |
|--------------------------------------|------------ |
| BABCEC1E-5FE2-46FA-9763-000131F2F688 | Active |
| 758F5201-4742-43C6-8550-000571875265 | Active |
| 5E51634C-4DD9-4B0A-BBF5-00087DF71C8B | Active |
| 0A4EA521-DE70-4D04-93B8-000CD12B7F55 | Inactive |
| 815C6C66-8995-4893-9A1B-000F00F839A4 | Proposed |
Rather than original, coded data like:
| id | BRIDGE_STATUS |
|--------------------------------------|---------------|
| F50214D7-F726-4996-9C0C-00021BD681A4 | 3 |
| 4F173E40-54DC-495E-9B84-000B446F09C3 | 3 |
| F9C216CD-0453-434B-AFA0-000C39EFA0FB | 3 |
| 5D09554E-201D-4208-A786-000C537759A1 | 1 |
| F0BDB9A4-E796-4786-8781-000FC60E200C | 4 |
but for an arbitrary number of columns.

MongoDB model for cross vendor time series data

I know my problem seems better be solved by RDBMS models. But I really want to deploy it using MongoDB because I have potential irregular fields to add on each record in the future and also want to practice my NoSQL database skills.
PE ratio and PB ratio data provided by one vendor:
| Vendor5_ID| PE| PB|date |
|----------:|----:|-----:|:----------|
| 210| 3.90| 2.620|2017-08-22 |
| 210| 3.90| 2.875|2017-08-22 |
| 228| 3.85| 2.320|2017-08-22 |
| 214| 3.08| 3.215|2017-08-22 |
| 187| 3.15| 3.440|2017-08-22 |
| 181| 2.76| 3.460|2017-08-22 |
Price data and analyst covering provided by another vendor
|Symbol | Price| Analyst|date |
|:------|-----:|-------:|:----------|
|AAPL | 160| 6|2017-08-22 |
|MSFT | 160| 6|2017-08-22 |
|GOOG | 108| 4|2017-08-22 |
And I have key convert data:
| uniqueID|Symbol |from |to |
|--------:|:------|:----------|:----------|
| 1|AAPL |2016-01-10 |2017-08-22 |
| 2|MSFT |2016-01-10 |2017-08-22 |
| 3|GOOG |2016-01-10 |2017-08-22 |
| uniqueID| Vendor5_ID|from |to |
|--------:|----------:|:----------|:----------|
| 1| 210|2016-01-10 |2017-08-22 |
| 2| 228|2016-01-10 |2017-08-22 |
| 3| 214|2016-01-10 |2017-08-22 |
I want to execute time range query fast. I come up with an idea that store each column as a collection,
db.PE:
{
_id,
uniqueID,
Vendor5_ID,
value,
date
}
db.PB:
{
_id,
uniqueID,
Vendor5_ID,
value,
date
}
db.Price:
{
_id,
uniqueID,
Symbol,
value,
date
}
db.Analyst:
{
_id,
uniqueID,
Symbol,
value,
date
}
Is this a good solution? What model do you think is the best if there are far more data to add by different vendor?
I would consider using nested table or child table approach. I am not sure the extent of support mongo has for this kind of support. I would consider using Oracle NoSQL Database for this usecase with nested tables support with TTL and higher throughput (because of BDB as storage engine). With nested tables you could store PE and PB with timestamps in the child/nested table while the parent table continues to hold symbol/vendor_id and any other details. This will ensure that your queries are on the same shard, putting them in a different collection will not guarentee same shard.