database

VARCHAR as foreign key/primary key in database good or bad?

Is it better if I use ID nr:s instead of VARCHARS as foreign keys? And is it better to use ID nr:s isntead of VARCHARS as Primary Keys? By ID nr I mean INT! This is what I have now: category table: cat_id ( INT ) (PK) cat_name (VARCHAR) category options table: option_id ( INT ) (PK) car_id ( INT ) (FK) option_name ( VARCHAR ) I COU...

Can you do queries against two databases if mysql_select_db was already used?

I have code that in the connection setup selects the database using mysql_select_db(). $link = mysql_connect('localhost', 'user', 'pass'); mysql_select_db("database1"); Can I later run a query against two databases such as: SELECT database1.row, database2.row FROM database1.table, database2.table WHERE database1.row = database2.oth...

grails database migration

Hi, There are at least two Grails plugins that emulate the database migration functionality of Rails. Autobase Liquibase Is there a consensus about which of these is best, or is there another plugin that does database migration which is better than either of the above? Thanks, Don ...

My final mysql db, could someone check if the tables are correctly made?

I have these tables: category table: cat_id (PK) cat_name category_options table: option_id (PK) cat_id (FK) option_name option_values table: value_id (PK) option_id (FK) value classifieds table: ad_id (PK) (VARCHAR) something like "Bmw330ci_28238239832" poster_id (FK) cat_id (FK) headline description price etc.... posters table: po...

Why are such specific data types needed when creating database tables?

Take the following create table statement: create table fruit { count int, name varchar(32), size float } Instead of those specific data types, why not have "string", "number", "boolean" or better yet, not having to specify any data types at all. What are the technical reasons for having such specific data types? (as opposed to...

How do you know when you need separate tables?

How do you know when to create a new table for very similar object types? Example: To learn mysql I'm building a model solar system. For the purposes of my project, planets have many similar attributes to dwarf planets, centaurs, and comets. Dwarf planets are almost completely identical to planets. Centaurs and comets are only different...

How to export data from the database into .csv format programmatically?

I have stored some data in MySQL database through a java program. Now I want to export that data from the same program in .csv file. I know One method of doing this is to get all the fields of one row in variables and then store them in a file by seperating them with a comma(,) and by repeating the same for every row in the database. B...

Designing database interaction while following Single Responsibility Principle

I'm trying to adhere to Single Responsibility Principle better, and I'm having issues grasping how to structure the general class design for communicating with a database. In a simplified version, I essentially have a database containing: Manufacturer <== Probes <==> ProbeSettings A probe has a manufacturer. A probe has 1 set of se...

Designing archive in database. Some patterns maybe?

We are currently doing an web application which one of the functionality is to create Events by the user. Those events can be later on deleted by the user or administrator. However the client requires that the event is not really physically deleted from database, but just marked as deleted. User should only see non-deleted events, but ad...

Why is my Slave not starting on MYSQL?

mysql> start slave; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> show warnings; +-------+------+--------------------------+ | Level | Code | Message | +-------+------+--------------------------+ | Note | 1254 | Slave is already running | +-------+------+--------------------------+ 1 row in set (0.00 sec) mys...

In a master-master setup, what command or files do I edit so that it can auto-increment by 2?

One server increment 1, 3, 5. The other server increment 2, 4, 6 ...

How to link sql database entries?

I have a SQLite database of notes that have columns _id, title, details, listid _id is the auto incremented primary key title and details are string data fields listid is a foreign key pointing to a list name in another table. I'd like to find a way to have notes that are in multiple lists or notes that are linked in such a way tha...

Is there any harm in resetting the auto-increment?

I have a 100 million rows, and it's getting too big. I see a lot of gaps. (since I delete, add, delete, add.) I want to fill these gaps with auto-increment. If I do reset it..is there any harM? If I do this, will it fill the gaps?: mysql> ALTER TABLE tbl AUTO_INCREMENT = 1; ...

Good alternative to SQL access on iPhone

I am working on an app for a business that is essentially a catalog. The client has a website that uses a MySQL database, but he doesn't want that to be used by the app. His website offers RSS feeds, but I don't think that this would be a good idea. The app is supposed to be searchable based on a number of (optional) factors and show det...

MySQL Query - Result Table Name

When I query a mysql database in PHP, I can not figure out how to specify the table of the field in the result set. For example, I would like to do the following: $row = mysql_fetch_assoc($result); $row["table.FIELD"]; But, can not figure out how. Surely, it is able to happen somehow. EDIT: I have checked documentation, and have f...

Open source libraries for abstracting database access in C++?

I'm looking for options for abstracting database server details away from my application (in c++), I'd like to write my code to be independent of the actual database backend. I know MySQL has a nice library, but I don't want to be tied to a single database implementation. Are there good options for this? ...

Using a table to provide enum values in MySQL??

Is there a way to map one of the the columns contents of a MySQL table to an enum on another table in MySQL? I thought this would be a no brainer, but there doesn't seem to be any info that I can find on the subject. Any advice or help on this matter would be cool and if it's not possible, does anyone know of an internal reason why it w...

How to develop database application on Mac?

Hi, I want to implement Native Mac application with Database. How can i implement database application? Can anyone give me some sample tutorial to start? Thanks, Jim. ...

What is a good tool for the investigation of Database Connection usage in Java?

What is a good tool for the investigation of Database Connection usage in Java? A developer is supporting a complex Java program which is ocassionally exhausting the number of Database connections available. Since the problem is sporadic it would be useful to know which thread has opened multiple connections to the database to focus the...

Database table design optimise for high volume data

If i were to organise data on tourism and hotel for the continent of Australia and south America can you let me know a best way to do it. Like if i organise the tables thus: continents countries states zipcodes cities destinations hotels lnkhotelszipcodes (in case a hotel exists in multiple places) lnkhotelscities It will be search ...