The data is from Chrome Google history file.
I want to know the meaning of columns in tables. So I find one table called visits in the history is:
CREATE TABLE visits(id INTEGER PRIMARY KEY,url INTEGER NOT NULL,visit_time INTEGER NOT NULL,from_visit INTEGER,transition INTEGER DEFAULhT 0 NOT NULL,segment_id INTEGER,is_indexed BOOLEAN)
The table's result is :
1|10|12979306250150765|0|268435457|1|0
17|14|12979306291009421|0|838860801|2|0
18|14|12979306291724492|0|805306368|0|0
19|14|12979306296042195|0|838860808|0|0
20|14|12979306296322297|0|805306368|0|0
21|14|12979306298922534|0|838860808|0|0
22|14|12979306299261896|0|805306368|0|0
23|15|12979306305614105|0|805306368|0|0
24|15|12979306310110294|0|805306368|0|1
25|16|12979306316672464|0|805306368|0|1
So, another table called urls, which is also in this history sqlite is:
CREATE TABLE "urls"(id INTEGER PRIMARY KEY,url LONGVARCHAR,title LONGVARCHAR,visit_count INTEGER DEFAULT 0 NOT NULL,typed_count INTEGER DEFAULT 0 NOT NULL,last_visit_time INTEGER NOT NULL,hidden INTEGER DEFAULT 0 NOT NULL,favicon_id INTEGER DEFAULT 0 NOT NULL)
The table's result is:
1|http://cateee.net/xxxx|Linuxxxx|0|0|0|0|0
2|http://kernel.org/|Index of xxxxxxxxx|0|0|0|0|0
3|http://repo.orxxxxxxxxxxxxx|xxx|0|0|0|0|0
4|http://stackoverflow.com/xxxx|xxxxxx|7|0|12979644275181782|0|0
5|http://stackoverflow.com/questions/xxxxxxx|linuxxxxxxxxxxxxxxxx|0|0|0|0|0
6|http://www.db-class.org/xxxxxxxxxxxxxxxx|xxxxxxx|6|0|12979306496245203|0|0
7|http://www.xxxxxxxxxxxxxxxxxxx|xxxxxxxxxxxxxxxxxx|0|0|0|0|0
8|http://www.xxxxxxxxxxxxxxxx|xxxxxxxxxxxxxxxxxxx|0|0|0|0|0
10|http://www.google.com/|PYTHON - Googlexxxxxxxxx|1|1|12979306250150765|0|0
14|http://www.facebook.com/|Facebook|6|2|12979306750272709|0|0
15|http://www.facebook.com/profile.phpxxxxxxxxx|xxxxxxxxxxxxxxx|2|0|12979306310110294|0|0
So my problem are: is the urls table's first column called url_id represents in the visits table's second column called url INTEGER, but the relationship is not clear. And what is the meaning of transition INTEGER in visits table, can I extract the time from these, I need to get useful information from these tables, and make their relationship clear.
This site had a lot of helpful information about Chrome's SQLite tables, and how to query the tables.
An example they give on that page of joining the two tables "urls" and "visits" is as follows:
SELECT urls.url, urls.title, urls.visit_count, urls.typed_count, urls.last_visit_time, urls.hidden, visits.visit_time, visits.from_visit, visits.transition
FROM urls, visits
WHERE
urls.id = visits.url
And as for the "transition" field in the visits table, this value tells you how the URL was loaded into the browser. I'll let you check out the link I gave you for more details.
Related
I'm trying to define a LOV with Universe Designer that when used in a #Prompt shows the user the item description, but gives back the corresponding item key as result of user selection.
e.g. From a dimension table of countries with two columns as COUNTRY_ISO and COUNTRY_NAME, I would like to show COUNTRY_NAME values to user with #prompt, but get back the corresponding COUNTRY_ISO as return value of #prompt.
This is possible using Index Awareness. I'll describe the solution using the sample "Island Resorts Marketing" universe, but the concept should map to your specific need.
For this example, we'll create a prompt on the "Country" object in the "Resort" class. The prompt will display the country names, but the condition will apply to the country_id field.
First, we need to identify the keys. On the Keys tab of the Resort\Country object, add a new Primary Key using Resort_Country.country_id as the source:
(in your case, you'll do this on the COUNTRY_NAME object, using COUNTRY_ISO as the primary key)
Next, we create the predefined condition that will include the prompt. Create a new Predefined Condition, named "Select country", with the following definition:
Resort_Country.country_id = #Prompt('Choose a country','A','Resort\Country',Mono,primary_key)
What we're doing is is applying the condition to the ID field (resort_country.country_id), but using the country name (the Country object) as the source. Note the "primary_key" parameter -- this tells BO to use the PK from the referenced object.
Now to test. Create a WebI report and select the "Select country" filter along with a field to display. I chose Service Line:
I run the report and am presented with a list of country names. I choose France, and I get a list of the Service Lines associated with France. The SQL generated by this query, reflecting my prompt selection, is:
SELECT
Service_Line.service_line
FROM
Service_Line,
Country Resort_Country,
Resort
WHERE
( Resort_Country.country_id=Resort.country_id )
AND ( Resort.resort_id=Service_Line.resort_id )
AND ( Resort_Country.country_id = 2 )
Note the very last line, which shows that the condition is applied using the ID, even though I selected the country name "France".
References:
- XI3.1 Designer Guide #Prompt info, starting on page 520
- Dave's blog on Index Awareness
- Dave's blog on Index Awareness with prompts
I have an IDB object store "feeditems" with the keypath ["feed_id","item_id"], and inserting objects with os.put({feed_id:1,item_id:2,text:"foo"}); works fine.
Now I'd like to get a count of all feeditems where the feed_id is 13. The problem is that even the usually good MDN docs at https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore only say that the key parameter is "The key or key range that identifies the records to be counted.", yet a os.count({feed_id:13}) fails with a DataError exception "The parameter is not a valid key.".
So, how do I get the count of (and later, how do I iterate through) all the items with feed_id==x?
Note that the uniqueness is only combined for feed_id and item_id - there may very well be one entry with {feed_id:1,item_id:1} and one with {feed_id:2,item_id:1}!
You still need to index the field, feed_id, that you want to query. An then count the index. Compound index is irrelevant for this query.
var index = objectStore.index('feed_id');
var req = index.count(IDBKeyRange.only(13);
I have a named scope set up in my rails application that is used to locate a record either by its ID (directly from the index view) or a UUID (from an email - basically only so that users can't enter in any ID and view a record)
scope :by_uuid, lambda { |id| where('id = ? OR uuid = ?', id, id) }
This is used in the show action, so the ID comes from the url, like
services/114
services/74c083c0-8c29-012f-1c87-005056b42f8a
This works great, until you get a UUID such as 74c083c0-8c29-012f-1c87-005056b42f8a
This, rails unfortunately converts to the int value and we get services/74 AS WELL AS the record with the correct UUID
Adding a .first to the scope will not help because the order could be different for each record, so that does not work.
Is there a way to prevent rails from converting the ID like this and taking the string literally? Obviously, there will not be a record with an ID that matches that, but if it goes willy-nilly with the integer values of the string passed to it, we could get anything back.
Using the dynamic finders, such as
Service.find_by_uuid
or
Service.find_by_id
work as intended, however we need to be able to retrieve a record using the UUID OR the ID in the same method (show).
Is there a way to do something like
Service.find_by_id_or_uuid
We fixed this issue with the following change to the scope:
scope :by_uuid, lambda { |id| where('binary id = ? OR uuid = ?', id, id) }
This ensures that the id string is taken by its binary value instead of being converted into an int. However, this will ONLY WORK WITH MYSQL BASED APPS
OK - I updated from Horde Webmail 3 to Horde Webmail 4.
In that transition, the 'horde_prefs' table now shows that the 'pref_value' field is of type BLOB. Previously, it was of type LONGTEXT.
When setting up new accounts, I want to give all of the users default preferences before the user logs in - to ensure that they all have the proper default preferences.
Before, I simply created a PHP script with all of the default values as SQL entries - and inserted them with the username. Now, because these are BLOB entries, I cannot do so.
So in essence, the table has four fields:
pref_uid (the username)
pref_scope (the application that the preference is set for - like horde, ingo, imp, etc)
pref_name (the name of the preference - such as last_login, last_maintenance, etc)
pref_value (the BLOB entry that contains the actual preference)
So - there might be 20+ rows for one user account and all the preferences.
I'd like to copy all of the rows from one user (say tester#test.com) to make the default preferences for the new user (say newuser#test.com)
Is there any way that this can be done?
Thank you!
It is possible like the following:
insert into horde_prefs(pref_uid, pref_scope, pref_name, pref_value)
select 'newuser#test.com', pref_scope, pref_name, pref_value
from horde_prefs
where pref_uid='tester#test.com'
the insert into .. select .. works with blobs too.
[Edit: Apparently, this is only an issue for arrays and FoxyBOA's answer might direct to (or even is) the answer.]
My question relates to these software: Hibernate3+Annotation, Spring MVC, MySQL and in this example also Spring Security.
I was wondering, why collections, which are automatically associated by Hibernate contain null values for each row number of the child table (besides the elements which are correct). My Example:
I have a users and an authorities table, the primary key of the users table is username which serves as foreign key. Right now, there are 13 rows in my authorities table. When I retrieve a user from the database (MySQL InnoDB) and Hibernate automatically retrieves the user's authorities corresponding to this mapping:
#OneToMany
#JoinColumn(name = "username")
#IndexColumn(name="id") // "id" was the primary key and is used to sort the elements
public Authority[] getAuthorities() {
return authorities;
}
public void setAuthorities(Authority[] authorities) {
this.authorities = authorities;
}
... I end up with a collection "authorities" containing 14 (0-13) elements of which only four are not-null (four rows in the database table belong to that specific user, so that is correct). As far as I realize, I am using Hibernate defaults for properties like Fetchmode etc. I am getting the user like this:
Criteria criteria = getSession().createCriteria(User.class);
criteria.add(Restrictions.eq("username",username));
User user = (User) criteria.uniqueResult();
The logging information from org.hibernate.loader.loader correctly "mentions" four rows for the resultset. Still, the user created has the four correct elements plus ten null values in the Array. In my specific example, this results in this exception:
java.lang.IllegalArgumentException: Granted authority element 0 is null - GrantedAuthority[] cannot contain any null elements
The answer lies in the #IndexColumn annotation. It is using the value of id as the array index, thus the number of elements in the Array is basically going to be the value of the highest ID in the Authorities table.
see the hibernate documentation on indexed collections
try removing the annotation.
Also just as a thought; have you considered using a Set for the mapping? it isn't strictly necessary, it just a bit more common form of mapping that's all.
I can recommend you check your data. If you have a missed indexes (id column in your case), then instead of missed id you'll get null in your array.
I.e.
table authorities:
username id
bob 1
bob 3
bob 5
As a result you will have an array:
{0=null, 1=bob, 2=null, 3=bob, 4=null, 5=bob}
UPDATE:
I met the situation in two cases:
Missed key values in indexed column id at authorities table (e.g. 0,1,3,4,5 - missing value 2. Hibernate will automatically add to an array value with key 2 and value null).
Indexed values are in order, but select criteria filter part of them (e.g. your HQL similar to that "from user u join u.authorities a where a.id=2". In that case hibernate load a user, but in authorities array you will have only 3 values: 0 - null, 1 - null, 2 - authority with id 2).