database

Key problem: Which key strategy should I use in my database?

Problem: When I use an auto-incrementing primary key in my database, this happens all the time: I want to store an Order with 10 Items. The ordered Items belong to the Order. So I store the order, ask the database for the last inserted id (which is dangerous when it comes to concurrency, right?), and then store the 10 Items with the for...

How to fetch an object graph at once?

I'm reading a book, where the author talks about fetching an row + all linked parent rows in one step. Like fetching an order + all it's items all at once. Okay, sounds nice, but really: I've never seen an possibility in SQL to ask for - lets say - one order + 100 items? How would this record set look like? Would I get 101 rows with mer...

How to solve the A/B key problem?

I have a table my_table with these fields: id_a, id_b. So this table basically can reference either an row from table_a with id_a, or an row from table_b with id_b. If I reference a row from table_a, id_b is NULL. If I reference a row from table_b, id_a is NULL. Currently I feel this is my only/best option I have, so in my table (which ...

Is there an answer matrix I can use to decide if I need a foreign key or not?

For example, I have a table that stores classes, and a table that stores class_attributes. class_attributes has a class_attribute_id and a class_id, while classes has a class_id. I'd guess if a dataset is "a solely child of" or "belongs solely to" or "is solely owned by", then I need a FK to identify the parent. Without class_id in the ...

How to support Multi-Languages approach in DataBase Schema ?

Hi, I want my database to support multi Languages for all text values in its tables. So what is the best approach to do that?. Edit1:: E.G. I've this "Person" table: ID int FirstName nvarchar(20) LastName nvarchar(20) Notes nvarchar(max) BirthDate date ........... So if i want my program to support new language "...

Is it a good idea to incorporate a Reference Count into every database table?

From Objective-C i'm used to Reference Counting / Retain Counting (same thing). I love this concept, and it's plain simple. So I thought, why not apply this to a database? The problem is: Imagine these tables: users, photos. A user can own a photo, a user can like a photo of himself or someone else, and a user can recommend a photo. In...

Handling variety of content types in the persistence layer.

Hello. In my site, I'll be inviting people to contribute variety of content, like pictures, video, and things alike. Besides the core content, I'll be capturing meta data. Some meta data will be common across content types and some will be specific. I am planning to have 1 table that accommodates universe of meta data with that many c...

DB in MySQL migrate to Oracle DB

Hello. I need to migrate some tables in mysql db to oracle db. Do you now any tutorial to learn about this migration? Thanks ...

What should every developer know about databases?

Whether we like it or not, many if not most of us developers either regularly work with databases or may have to work with one someday. And considering the amount of misuse and abuse in the wild, and the volume of database-related questions that come up every day, it's fair to say that there are certain concepts that developers should k...

Freely available example datasets of hierarchical information, and realistic names

I'm about to write some example applications and accompanying documents comparing ways of accessing information stored in relational databases. To demonstrate real-life requirements, I need to include a realistic dataset of hundreds of thousands of facts. Is anyone aware of publicly available, free datasets of that magnitude, of dataset...

High-Performance Hierarchical Text Search

I'm now in the final stages of upgrading the hierarchy design in a major transactional system, and I have been staring for a while at this 150-line query (which I'll spare you all the tedium of reading) and thinking that there has got to be a better way. A quick summary of the question is as follows: How would you implement a hierarchi...

combine master and detail information in query result

Using openoffice.org Base 3.1.1 Given the database below with three tables, I would like to create a query with the following output. How can this be achieved with queries or views? output book.title, tags title 1, tagdescription1 tagdescription2 tagdescription3 title 2, tagdescription2 database BOOK id - primary key,title 1, title...

Execution times for various RDBMS queries?

Is there some reliable (i.e. acknowledged) data on the execution times for various queries, such as different types of joins, scans, with different types and size of data? I am looking for the order of magnitude. This does not have to be vendor-specific data. It should be similar in terms of presentation for latency for various access t...

Fetch records from one table where there's not a record in another

SURVEYS table: SurveyID UserID Question Choice1 Choice2 Choice3 RESPONSES table: UserID SurveyID Answer The first desire (achieved): Show me all surveys that User 28 has initiated: SELECT * FROM Surveys WHERE Surveys.UserID = 28 The second desire (achieved): Show me all surveys that User 28 has answered: SELECT * FROM...

JSON, Javascript & Dynamically Created & Populated Tables

I've got the following JSON structure that defines a table and it's data. var arrTable = [{"table": "tblConfig", "def": [{"column": "Property", "type": "TEXT NOT NULL"}, {"column": "Value", "type": "TEXT NOT NULL"}], "data": [{"Property": "VersionNumber", "Value": "1.0"}, {"Property": "ReleaseDate", "Value...

How to read Database DUMP .DMP Files

i have .dmp file of a database , dun know sqlserver or oracle....how can i read data from it ....extention is .DMP.......what to do..... ...

Generaly in database design what is better one table with two references or one table?

Let's say i have people who search for jobs, and i have a list of jobs. So i have two tables: people and jobs. Now i have a list of skills of the person, and i have a list of skills for the job requirement. What is better to have ONE skills table like this: CREATE TABLE skills_reference ( id INT, reference_id INT, -- can reference peop...

Maintaining A Secondary, Relative ID Column

Hey, I'm looking for the most efficient way to maintain an object relative auto-incrementing value. In other words, I have a table of objects, and a table of child objects. The child objects need to have a column, which increments relative to the other child objects for the same parent. (ie. child object 3 of parent object 4) eg. Paren...

android simplecursoradapter not updating with database changes.

I have an android list activity that is backed by a database cursor through a SimpleCursorAdapter. When the items are clicked, a flag field in the coresponding row in the database is toggled and the view in the list needs to be updated. The problem is, when the view that's updated goes off screen and is recycled, the old value is ...

Data source for all the roads in the world?

For no reason in particular, I'm curious what the expected number of feet you would have to walk to find the nearest road is, starting from a random point on the world, facing a random direction. I can write a program to compute this value, given the right data source. Is there any data source containing all the roads in the world? For ...