Crime Data Warehouse [closed] - data-warehouse

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I am a IT student and now facing problem in understanding data warehousing. I need to implement a data warehouse that will be used in State police department for crime analysis. But I am not sure how to do with measure. I will use star schema. I want to set the business question from the view of Chief office , so I guess the measures should be No of crimes, No of offender and No of victims, and I am not sure.. May I know the fact table (measures).

I would start by writing down everything you know about crime. For example:Police, Detectives, Locations, CrimeType, Crime Instance etc.
Theses could be your tables.
Link the data in the tables to make it into a database. The data in the tables may be something like:
Location: Name, Address, Type, creationDate, user
Crime: Name, Severity, Punishment, creationDate, user
CrimeIntance: Crime, Location, Date, Detective, creationDate, user
etc, etc - use your imagination

Related

Best practice for Like feature in social network app with ParseDB [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm need to add new 'Like' feature to existing Social Network iOS app.
The user can do 'Like' action on comments of other users.
1) If the the user hits 'Like' the comment will be marked as 'Liked' by the user.
2) I need to display the 'Likes' count in the comment view.
3) If the user hits the count of the 'Likes' he can see the list of the users that did 'Like'.
My approach was to add new table to the ParseDB called 'like' with columns - ' commentID, userID. When the comment will be display, I'll make a query to the 'like' table and fetch the users that 'liked' the comment.
Is it the correct approach or this will be cause IO delays in the UI?
please give answer if you have experience with ParseDB only.
IMO solution in OP will work but you might want to consider two additional options.
In order to minimize metered query costs consider 'likes-ctr' column on 'comments. Like button cliks ++ this.
To flaten the query that join users to comments which they liked consider Array type colum. On 'comments' that hols pointer to user. APIs have ' addUniq' which nicely handle updating an array with poiter to user as long as u have ref to currentUset object.
Query.include('usersLiked')
Added will do the he join work

Data Warehouse example - simply explained [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm trying to learn about Data Warehouses right now, but I really don't get it. My question isn't really specific, but I just want somebody to explain to me the idea of data warehouses.
I'm trying right now to create a data warehouse out of SO's database.
In this database there are 8 tables, they are pretty self-explanatory for those who use SO:
Badges
Comments
PostHistory
PostLinks
Posts
Tags
Users
Votes
1. Dimensions
What would be the dimensions? That's the big part I don't understand. For me I see 7 dimensions: Badges, Comments, Posts, PostLinks, Tags, Users and Votes. But then I don't see the point of using data warehouses, the dimensions are exactly the tables.
-Would date be a dimension? Date of what? Of each comment AND post?
-Would it be relevant to separate Post into a Question dimension and an Answer dimension?
-What other dimensions can I put?
2. Fact Table
How can I put all the foreign keys (userId, postId, commentId...) in one table? For example, let's say a user posts a question but there's no comment. I would have a line in my fact table with his userId, the postId an NULL in the commentId column?
Measures. I'm thinking of the following measures in the fact table: number of questions, number of users, number of tags...
Can someone tell me about if I'm going in the right direction?
The first question you have to answer when building a data warehouse is "What question(s) do I want to answer?"
Using Stack Overflow as an example, one question could be, "How many posts are there about X each month over the last 2 years?"
To answer this question, we need to create Posts and Post Tags fact tables. Since these tables are select and insert only, we can denormalize the fact data so it's easier to select.
So, we might have a Post fact table that looks something like this.
Post
----
Post Number
Post Text
Post Timestamp
Post Tag 1
Post Tag 2
Post Tag 3
Post Tag 4
Post Tag 5
It would be somewhat straightforward to select based on the timestamp and group by month. We only care about the first 5 post tags, and we don't care if some of them are null.
Now, you don't have to denormalize the data. Generally, queries run faster if you denormalize the data.
You do the same thing for the other data available. What question(s) do you want to answer?
Stack Overflow is probably not the best data model to consider if you're trying to wrap your head around the concept of DW. It doesn't contain many "traditional" facts. The only examples which jump to my mind immediately are the Up/Down votes and the user rankings.
You would find many, of what we call "factless facts". These essentially treat the intersection of multiple dimensions as a fact, with just an implied "count" as the sole fact. As an example, in the Post Fact, it would simply be a count at the intersection of User, Date, SO Database, etc.
You would probably consider a concept such as the Junk dimension to support referencing the Tags in a Fact table. This would see you assign a pseudo key to each unique combination of Tags, and then this key is what you would store in the Fact table.
If you want to learn about DW, use your personal finances, this is how I learned. You can learn about snapshot facts with your account balances, you can learn about transactional facts with your purchases, and you can create Vendor and Account dimensions, among others.

iOS Swift - Core Data examples with a complex data relationship [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm trying to understand how to model complex data relationships with Core Data.
With my app, I currently have an entity of Recipe, Ingredient and RecipeIngredient which bind ingredients to a recipe.
I have not come across any example of fetching data out of this joint entity. I'd appreciate it if someone could give an example of an entity like my RecipeIngredient in Swift.
The reason you haven't seen examples similar to your RecipeIngredient entity is that you don't need joint entities like that in Core Data. You're treating Core Data as if it were a relational database, where you'd typically use a join table in order to create efficient many-to-many relationships between entities. As explained in the Many-to-Many Relationships sub-section of the Core Data Programming Guide, with Core Data all you need to do is to specify a to-many relationship in both directions between two entities. Note the parenthetical remark in the docs:
(If you have a background in database management and this causes you concern, don't worry: if you use a SQLite store, Core Data
automatically creates the intermediate join table for you.)
Here's an illustration of the relationship as you should model it, ripped straight from Xcode's model editor:
If you'd still like to see examples of how to do this, search for something like "Core Data many to many relationships" and you'll find plenty. You could start here on StackOverflow; a quick search turned up a number of examples, including How do you manage and use "Many to many" core data relationships?.
Update: From your comment, I understand that you want to use an intermediate object to add information about the relationship between recipes and ingredients. That is a case where another entity is warranted. So let's say your model looks like this:
It seems unlikely that you'd want to fetch one of these RecipeIngredient objects directly; you'd probably just follow the appropriate relationship. So, you might create a fetch request to find all the Recipes whose name matches #"chocolate cake". (There are plenty of examples of fetch requests using a predicate in the docs and all over the net, so I won't do that here.) Your fetch request will return an array of recipes that we could call cakeRecipes, but you're probably only interested in one:
Recipe *cake = cakeRecipes.firstObject;
Now, what do you want to know about the ingredients for your cake? Here's a list of the ingredients:
NSArray *ingredientNames = cake.ingredients.ingredient.name;
If you'd like to log the ingredient names and amounts:
for (RecipeIngredient *i in cake.ingredients) {
NSLog(#"%# %#", i.amount, i.ingredient.name);
}
Or, you could use a fetch request to find the ingredients matching "celery", storing the result in celeries. After that, you might look for recipes including celery:
Ingredient *celery = celeries.firstObject;
NSArray *recipes = celery.recipes.recipe
If this doesn't help, perhaps you could be more specific about the problem. Also, I know you asked for Swift, but my fingers are still used to Obj-C, and the language specifics don't really come into play here -- Core Data works the same in both languages.

Properly gathering metadata/object data using Core Data/sqlite [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm new to objective c and core data. I am making an iOS app kind of like a flash card app. I have a core data set up with an EnglishWord entity in a many to one relationship with ForeignWord entities (different languages).
For each ForeignWord entity I want to keep track of certain metadata: how many times I have viewed the word, the dates I viewed it, a score I give it, etc. Ideally would be if I could have an array/dictionary as an attribute within the ForeignWord managed object itself. This is not possible.
The only option I can think of is to create a new entity called 'Score', with each ForeignWord entity 'owning' many Score managed objects (one to many), a new 'Score' managed object being created every time I view the foreignWord.
However, this sounds very messy. If I have 1000 words then I would have 1000 different tables in the sqlite database, one for each card.. does that slow things down? is it bad to have 1000 different tables?
is this really the way to do it? Is there a more elegant solution? Thanks!
You might consider adding a table called something like "Viewing" that has a relationship (to 1) both to EnglishWord and ForeignWord. You could then track the metadata that interest you in this table and aggregate the data in this table to determine how many times that you viewed a particular word, whether or not you identified it correctly, etc.
I would create one new table called ViewEntry or something and link relationships to both of your word tables. That way when a word is viewed you can store whatever meta information you want, as well as having an active link to the English and foreign version. Something like this:
This way you can create a new ViewEntry set its foreignVersion and word attributes to the English and foreign words, set the date, score, and total answer time (along with anything else you want). You could then do some really nice querying to pull up useful information.
give me all of the foreign versions of the English word "school" where the score was less than 50%.
I want all of the times the user attempted the Russian translation of "house" and the associated scores.
what English words have the worst/best score?
what is the most/least view English (or foreign) word?
All of this would be relatively easy since the English word could access all of the times it was viewed and any foreign version of any English version could do the same. You could also access the score and view date and pull up all of the English/foreign versions from that data.
You also would not need to create 1000 tables :)

Dynamic forms and models in rails [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I have been trying to figure out how eBay would create their forms in rails. (FYI I know that they don't use rails). So far I have come to the conclusion that their could be two models
Posts "<- would contain the basics every post contains"
-
Post_id
User_id
Category_id
Photos
Title
condition
Location
Price
This is pretty simple, but lets say a user wants to sell a car, the form would ask them for the mileage, model, year etc. But in contrast, if a user wants to sell a table, the form would not ask for the information it would generally ask for a car. Is their a way to accomplish this is rails without having to create many models and associating them with Posts?
I guess the simplest scenario would be thus:
"Category has a name" (this will keep "car", "bird", "soul", whatever they sell on e-bay)
"Property is made of a name, a value and a category"
"Product has many Properties"
Each product will have N properties belonging to a certain category.
Use-case (new category):
When you create a new category, you can create properties belonging to it, or add properties from existing other categories (composition)
Use-case (new product):
When you want to create a new product, you select a category and properties belonging to that category will be added dynamically to your product.

Resources