Infering the hash algorithm from input and output - cryptography

Say we have an image named 907251651.jpg. This image is on a webpage for a unique species, which can be uniquely identified by either its taxon id 165121, or its scientific name Lycopodium madeirense.
I have reasons to believe that the name of the image is computed based on either the taxon id or the species name (though I can't be sure).
Is there any way to infer how the image name might be computed ?

Related

determine maximum value of each row with the column name in Python

I have a table which's been attached.
The table includes a different number of model of cars with their EU class (columns are a number of models in each class).
I am trying to identify the maximum value of each model (at each row) by identifying the EU class (column name) in Python.
for example the first row the maximum number goes to Euro 5 with 3677 cars whose model of vehicle is 320 GH.
I tried different commands such as
maxValuesObj = D_high_model_EUstd.loc[D_high_model_EUstd['Model of Vehicle'].idxmax()]
but faced this error "reduction operation 'argmax' not allowed for this type".
I was wondering if anybody can help or suggest to me any solution.
Thanks
You can use pd.idxmax
For example:
df.drop(columns="Model of Vehicle").idxmax(axis=1) # Drop text column since idxmax don't work with them
Or create another dataframe:
pd.concat({
"Model of Vehicle": df["Model of Vehicle"],
"Max":df.drop(columns="Model of Vehicle").idxmax(axis=1)
},axis=1)

How to create inheritance in SQLite

I have to create an SQLite DB that models a survey with some ordered content; this content can be a question, an image or a simple text field (just like Google Forms). Each content doesn't have anything to do with the other, except questions which can have a list of attached images to them.
What would be the best way to model this situation? I thought about creating a "Survey" table and a "Content" table that has only an integer ID, and that same ID is then "duplicated" into each table ("Question", "Image" or "TextField"), but then I think I would have to insert both values for the Content and values for a specific content (Question, Image or TextField) every time I need to insert a new content. I don't think it would be a big problem, but if there is an way to model this better, I would like some advice.
Your approach is an example of 'table per type' as defined in this answer.
Conceptually, you're saying "there are 3 kinds of content, and the one thing they share is their relationship with a survey, as captured in the content table". You might include in that table an explicit type indicator along the ID - this will make your code a little more explicit. You may also find you need to capture meta data like "status", "date_entered" etc. which is common across subtypes.
By including a type indicator column, you make it easy to find out what the type of a content item is. So, if you want to show the summary of a question, you could do something like
select content_type, count(*)
from content
where question_id = ?
group by content_type
to show the number and type of responses.

Data Type Qualifiers Definition PostgreSQL

How would I go about defining a table with a language specific (qualified) attribute?
For example:
ID| object |description (english)|description (french)| size | color (english) | color (french)
in the above example we have 3 'normal' fields and 2 language qualified fields : description and color.
What is best practice for defining these type of fields within one table?
There are different ways of doing this. But a method for your specific data is to have another table with one row per language. Such as table would have:
objectLanguageId (serial column to identify the row)
objectId (reference to a table with one row per object)
language
description
color
Then the "object" table would have
objectId
objectName
size
Note: This is definitely not the only approach. If you need everything in your system translated, then you want a more sophisticated and generic mechanism. You may also need to take into account things like French sizes are different from sizes in other countries -- even countries that speak the same language.

How to differentiate products depending on attributes in a Point of Sale Database Schema

Here is my dilemma, I am building a POS system for a pretty large retailer, they have different products which have different attributes (size, color, etc...).
When they receive the merchandise from the supplier they want to do their own labeling with their own UPC Bar Codes but they also want to differentiate between the different sizes using the code on the article.
Say they received Brand A shirts with 4 sizes S,M,L,XL then they should have different bar codes for each size.
So I thought of having a base code for the article and then concatenating numbers depending on the attributes to have different codes? and if no attributes are available just add 0s
I am storing the sizes and colors as attributes in the database as an (Entity-Attribute-Value). Is their a better way other than having to start concatenating numbers from the attributes to come up with the full code?
Thanks for your help!
edit-------------------------------------------------------
I am making the example a bit clearer
so the base code for the shirts is: 9 123456
Then for Color blue is: 789
and then for size S: 012
so the full code is 9 123456 789012
for another article that doesn't have size or color or actually any attribute
the base code would be 9 654321
plus 000000 for the attributes part
this is just for simplicity sake as I can use only one digit per attribute.
The other issue is when linking to the OrderDetails table I need to reference all the attributes to know that the customer actually bought Size S in Blue
One possible option is to create a table that stores the bar code as the key. Then have an attribute for the size and the color.
Actually #jzd your answer is pretty close but I would like to keep the attributes as key value pair.
The idea is to use and an attribute set and have a bar code associated with each set. here is a rough schema
AttributeSet Table:
AttributeSetId
ProductId
AttributeSetName
BarCode
AttributeUse Table:
AttributeSetId
AttributeId
AttributeSetInstance Table:
AttributeSetId
AttributeId
AttributeValueId
if you forget the barcode for a minute...
do you have a database to track this inventory?
are the items stored discretely in this database?
if so, then just add a unique number to the item, called the UPC vale - i recommend not trying to make an intelligent key s\as you are describing

How to name my enum elements?

I have a problem naming the elements in my application's data model.
In the application, the user has the possibility to create his own metamodel. He does so by creating entity types and a type defines which properties an entity has. However, there are three kinds of entity types:
There is always exactly one instance of the type.
For instance, I want to model the company I am working for. It has a name, a share price and a number of employees. These values change over time, but there is always exactly one company.
There are different instances of the type, each is unique.
Example: Cities. A city has a name and a population count, there are different cities and each city exists exactly once.
Each instance of the type defines multiple entities.
Example: Cars. A car has a color and a manufacturer. But there is not only one red mercedes. And even though they are similar, red mercedes #1 is different from red mercedes #2.
So lets say you are a user of this tool and you understood the concept of these three flavors. You want to create a new entity type and are prompted to choose between option 1, 2 and 3. How would you name these options?
Edit:
Documentation and help is available to the user. Also the user can be expecteted to have a technical/programming background, so understanding these three concepts should be no problem.
First of all let me make sure I understand the problem,
Here's what you have (correct me if I'm wrong):
#of instances , is/are Unique
(1,true)
(n,true)
(n,false)
If so,
for #of instances I would use single \ plural
for is\are unique (\ not unique) I would use unique \ ununique.
so you'll get:
singleUnique
pluralUnique
pluralUnunique
That's the best I could think of.. I don't know exactly who are your users and what is the environment, But if you have an option of adding tips (or documentation) that should be used for sure.