database-design

db design questions (how to deal with groups of products, to make 2+2=3)

I would be grateful if somebody could help me to find an elegant solution to this database design problem. There is a company with a lot of different products (P1,P2,P3,P4) and a lot of customers (C1, C2, C3, C4). Now they have a simple database table to deal with orders, something like 20101027 C2 P1 qty status 20101028 C1 P2 qty status...

How to define polymorphism in JPA

Hi, there is a situation. For example, I am designing simple blog. There are articles and photographies. Users can add their comment to both of them. So when I write it in Java, it looks like this: public interface Commentable { ... } public class Article implements Commentable { ... } public class Photo implements Commentable { ... ...

EER tools for SQL Server

Is there any EER tool for SQL Server like MySql Workbench for MySQL ? ...

database table - data structure design c++

hi, this may be a dumb question or asked many times, i searched for it but did not find a proper answer. What is exactly going on when we type on SQL engine "Create table xxxx" how to implement this one in c++, i mean how it creates a variable dynamicalyy "xxxx" and store the data in it. If i queried "select * from xxxx" how it go to ...

Environmental database design

Hi everyone, I've never designed a database before, but I've had experience programming in a few languages and assembler throughout college, as well as some web design, so I'm able to at least pick up what I need to know if I can be pointed in the right direction. One of the tasks of my job is to sort through some data that we've been c...

Database Table Design

I want to know you opinion and what should be the best approach for this case: I have 2 table called: - clients; - suppliers; I've create 2 pages for people to leave feedback about a client and for a supplier. With that in mind a created a table feedbacks. Now the question is which approach should I choose: 1) Create one table calle...

Database design for recursive children

This design problem is turning out to be a bit more "interesting" than I'd expected.... For context, I'll be implementing whatever solution I derive in Access 2007 (not much choice--customer requirement. I might be able to talk them into a different back end, but the front end has to be Access (and therefore VBA & Access SQL)). The two ...

Alternatives to Entity-Attribute-Value (EAV)?

Hi, Our database is designed based on EAV (Entity-Attribute-Value) model. Those who have worked with EAV models know all the crap that comes with for the purpose of flexibility. I asked my client about the reasons why using EAV model (flexibility), and their response was: Their entities change over time. So, today they may have a tabl...

No direct access to data row in clustered table - why?

[11] tells: "In a nonclustered index, the leaf level does not contain all the data. In addition to the key values, each index row in the leaf level (the lowest level of the tree) contains a bookmark that tells SQL Server where to find the data row corresponding to the key in the index. A bookmark can take one of two forms. If the...

3CX Report from Database

i need to create various report from 3cx phonesystem database. i have phonesystem DB in postgreSQL. but i couldnt understand the DB Structure. Is there any documentation to study about 3cx phonesystem db. i have 3cx software. But for my report , i cant use that software. ...

Optimizing MySQL table structure. Advice needed.

Hi, I have these table structures and while it works, using EXPLAIN on certain SQL queries gives 'Using temporary; Using filesort' on one of the table. This might hamper performance once the table is populated with thousands of data. Below are the table structure and explanations of the system. CREATE TABLE IF NOT EXISTS `jobapp` ( `i...

What do I miss in understanding the clustered index?

In absence of any index the table rows are accessed through IAM ((Index Allocation Map). Can I directly access a row programmatically using IAM? Does absence of index mean that the only way to read specific row is full table scan reading all table? Why IAM cannot be engaged for more specific direct access? "If the table is a hea...

SQL Server data types: Store 8-digit unsigned bumber as INT or as CHAR(8) ?

Hello, i think the title says everything. Is it better(faster,space-saving according memory and disk) to store 8-digit unsigned numbers as Int or as char(8) type? Would i get into trouble when the number will change to 9 digits in future when i use a fixed char-length? Background-Info: i want to store TACs Thanks ...

Defining multiple foreign keys in one table to many tables

I have 3 models: Post: id title body Photo: id filepath Comment: id post_id body and corresponding tables in DB. Now, if I want to have comments only for my posts I can simply add following foreign key: ALTER TABLE comment ADD FOREIGN KEY (post_id) REFERENCES post (id). But I want to have comments for other models (photo, pr...

Relational database design - Two Relations 1:1 or one 1:2 ?

Hello everyone! This question is about how to design a SQL relationship. I am pretty newbie in this matter and I'd like to know the answers of (way) more experts guys... I am currently migrating a ZopeDB (Object oriented) database to MySQL (relational) using MeGrok and SqlAlchemy (although I don't think that's really too relevant, sinc...

What are the [dis]advantages of using a key/value table over nullable columns or separate tables?

I'm upgrading a payment management system I created a while ago. It currently has one table for each payment type it can accept. It is limited to only being able to pay for one thing, which this upgrade is to alleviate. I've been asking for suggestions as to how I should design it, and I have these basic ideas to work from: Have one ta...

Database Design Strategy : Product Table on E-Commerce System (EAV, Class Table Inheritance or Concrete Table Inheritance)

Hello guys! My E-Commerce System will have 5 bases type of products: Cell Phones Computers Shoes Shirts Default (No specific attribute) Each one have specific attributes associated... What I done (Class Table Inheritance): Product Id Name Sku Price ... Shoe ProductId Size Color ... Computer Prod...

Relational modelling question

We have three entities called Product, ProductType, and ProductCategory. Let's pretend we have three kinds of ProductType: Book, Music, and Video. We have three different ProductCategory's for Book: Fiction, Novel, Technical. Three different ProductCategory's for Music: Rock, Jazz, Pop. And we have three different ProductCategory'...

Why to add clustered index keys to all (intermediate) nodes on NCI?

Considering clustered table, Quassnoi wrote (the last phrase in answer): If the secondary index is declared UNIQUE, clustered key is appended only to the leaf-level records of the secondary index. This sounds like clustered key is added to (all) indermediate nodes of non-unique non-clustered index. And by the same logic RIDs are a...

How sequential traversing between intermediate leaves of clustered index used?

Intermediate leaves of clustered index are linked sequentially (next, previous) for faster access (between intermediate nodes) [2], [3], etc.: How this access is used? Why is it needed? [2] Clustered Index Structures http://msdn.microsoft.com/en-us/library/ms177443.aspx [3] Clustered Tables vs Heap Tables http://www.mssqltips.com/...