database

How Should I Design TAX Table?

I have a db with many tables. Some tables have unit price column, no tax, gst and such columns. What should i do now? Should i create GST table, HST table and PST table separately. In other words, what is the standard schema of designing the tax table? ...

NHibernate: link a collection via something other than the PK

Suppose I have the following tables: Company Person Address ---------------------------------------------------------------------------- Id (PK) Id (PK) Id (PK) Name CompanyId (FK) CompanyId (FK) AccessType AddressType Corresponding t...

How should I handle updating data in a one-to-many relationship database schema?

Lets say I have a database similar to the following: Table: People id | name | age ---+------+----- 1 | dave | 78 Table: Likes id | userid | like ---+--------+------- 1 | 1 | apples ---+--------+------- 2 | 1 | oranges ---+--------+------- 3 | 1 | women What would be the best way to handle updating daves data? Cu...

Optimizing a high insert/select/delete table

I have a transaction log table that basically is inserting, reading, and writing new records many times a second. It has about 5 rows with various ids in them. Aside from indexes/query modifications, is there anything specific to optimize a table like this? It's a MyISAM table type. Thanks! ...

Examples of android applications that use direct database access instead of content providers?

Just found out that I don't need content providers if I don't need to share data with other applications. But since the examples I've seen all use content providers, I'm not sure how to proceed without them and populate activities with data derived from accessing my application's database directly. ...

Is there a very simple front-end for MySQL tables?

Hi, I'm looking for a front-end that's very simple, to access a to-be-built MySQL Database. I actually need it for only one table. I was thinking that the user could search in a way that would ask for values for each field of that table, and give the option of leaving it blank. Then, it would return all the entries that match up with th...

Fastest way get random record from DB

I've been using order by rand() and it's becoming too much of a bottle neck. I've tried this SELECT id FROM users JOIN ( SELECT CEIL( RAND( ) * ( SELECT MAX( id ) FROM users ) ) AS id ) AS r2 USING ( id ) And it would work if all the id's were incremented, however with this particular table, they're not. The id's are fairly rando...

Extremely slow DB2 connectivity in Java

I am trying to connect to a IBM DB2 9 database on a Linux server from my Java application. I am using db2jcc.jar (DB2 Universal JDBC Driver). Establishing a connection takes a ridiculous amount of time? What could be wrong? I know there a lot of factors that could cause this, but I am willing to get down to the root cause. Please help me...

Are unique constraints on the DB necessary?

I've been wondering lately. Lets say we're doing a webapp with JSF+Spring+JPA/Hibernate (or well any other technologies) and lets say we have a "User" entity. We want the User to have a unique login. If we want to do it then we can put a @UniqueConstraint on the "Login" column, but still our application has to check during user registrat...

how to create a mdb file from a csv file in python?

I have several csv files that I need to transfer over to mdb format. I tried the answer in this post as a starting point: http://stackoverflow.com/questions/3094537/how-do-you-create-a-mdb-database-file-in-python Source: from comtypes.client import CreateObject access = CreateObject('Access.Application') from comtypes.gen import Acc...

Renaming a database model in Visio 2003

I have to translate a datamodel i Visio from one language to another. This can be done by using Edit -> Replace, but it only modifies the visual representation. The values in the database properties are not changed. That becomes a problem when Visio updates the layout and writes the values from the properties to the ER diagram. How can ...

Populate drop down list from database

I`m using this code to repopulate drop down list from the database : $city_id = 15; while($row = mysql_fetch_assoc($result)) { $selected = ($row['city_id'] == $city_id) ? 'selected="selected" ' : NULL; echo '<option value="'.$city_id .$selected . '">"'.$row['city_name'].'"</option>\n'; } It`s work like ...

MySQL : Does a query searches inside the whole table?

1. So if I search for the word ball inside the toys table where I have 5.000.000 entries does it search for all the 5 millions? I think the answer is yes because how should it know else, but let me know please. 2. If yes: If I need more informations from that table isn't more logic to query just once and work with the results? An exa...

Hosting Multiple Drawings in one Visio vsd Diagram

I'm using Visio 2007 and strawed creating some flowchart diagrams. One on each page. For the same project I would also like to create class and entity relational diagrams. Is it possible for me to have multiple drawing types in a single vsd? I tried creating an ERD by adding the Entity Relational shapes to my palette, but when I dragge...

SQL Performance (Replace)

Hey, I have a table that has about 400,000+ rows. I am writing some pattern matching code but need to clean up a column before I do so. This boils down to doing a replace-like operation. I tried listing them all out one at a time... Update T_ADDRESS set ADDR_LINEONE = REPLACE(ADDR_LINEONE,' southeast ',' se ') Update T_ADDRESS set A...

Creating DataBase (mdf) from DataSet

I have a DataSet consistint of a big number of tables of information. Is it possible automaticly create SQL Server DataBase (mdf-file) from description of my DataSet? Of course, I can do it manually, but may be there is a better way? ...

Should I expose a user ID to public?

Hi, I have a form that reveals user IDs to public. I was wondering that is this dangerous. Personally I do not see anything bad about it. The ID is just used to reference a single database record. ...

Extract Normal Form from XML

<Historic> -----<ReturnData Year="2010"> ----- -----<ReturnHistory> ----- -----<Return StoreDate="2010-07-31" Type="1"> ----- -----<EndDate>2010-01-31</EndDate> ----- -----<ReturnDetail TimePeriod="1"> ----- ----- -----<Value>2.83</Value> -...

CakePhp, getting total of many rows in a Containable.

Hi, I have a query using the Containable behaviors in cakephp thats looks like this : $x = $this->find('first',array('contain'=>array( 'User' => array( 'SelectionsTeam' => array('conditions' => $conditionTeamSelection, 'Team' => array( 'fields' => array('name','city','id'), ...

Generic extension method : Type argument cannot be inferred from the usage

I'm trying to create a generic extension method, that works on typed data tables : public static class Extensions { public static TableType DoSomething<TableType, RowType>(this TableType table, param Expression<Func<RowType, bool>>[] predicates) where TableType : TypedTableBase<RowType> where RowType : DataRow { ...