database-design

Dimensional Modeling: should a fact table have a foreign key?

Can a fact table have no keys at all? or if it can, is it a good design? If a fact table do not have any dimensions, on what basis is it analyzed? What if a fact table has primary key/s only and no foreign key/s? ...

Any ideas on how to implement flickr's tags clustering system? (preferrably in Rails)

I'm mainly just looking for a discussion of approaches on how to go from decentralized, non-normalized, completely open user-submitted tags, to start making sense of all of it through combining them into those semantic groups they called "clusters". Does it take actual people to figure out what people actually mean by the tags used, or ...

Database Architecture for "Badge" System & Arbitrary Criteria (MySQL/PHP)

Quickie-Question: To summarize, I'm a little confused as to how I would design such a database that allows indefinite badge-rule creation without requiring structural changes to the previously existing user-tables in the database. Storing Badge Title, Criteria, etc. What would that Table look like? badge_id (1) badge_title (10K Badge...

How do I express a polymorphic association in JPA?

A polymorphic association is similar to a foreign key or many-to-one relationship, with the difference being that the target might be one of a number of types (classes in the language, tables in the db). I'm porting a database design I've been using for some years from PHP to Java. In the old code, I had rolled my own ORM, which wasn't ...

Storing Waveforms in Oracle

I am designing a new laboratory database. I want to store the raw results for all tests together. However, results can either be a single measurement or a raw waveform. (repost see footer) Which case below is ideal (and why)? ... or provide your own ideal option. TEST test_id* (other TEST fields) OPTION 1: Separate single values...

How to store meta-data on columns

Let's say you're collecting insider info on upcoming superhero movie releases and your main Movie table looks something like this: Table 1 Title Director Leading Male Leading Female Villain -------------------------------------------------------------------------- Green Lantern Kubrick Robert Redford ...

Should I use a Foreign Key to Show Tree Relationship in SQL

I am trying to model a tree relationship in a table. For instance, there are "Categories" and categories can themselves be inside a Parent category. My schema is: id int PRIMARY KEY, parent_id int, name My question is, should I label the parent_id column as a Foreign key? Foreign implies "outside" and not self-referencing. Is ther...

Ideas on database design for capturing audit trails

How can I maintain a log of the data in my DB? I have to maintain a log of every change made to each row. That means that I can't allow DELETE and UPDATE to be performed. How can I keep such a log? ...

Are less tables better than more?

I'm implementing a small time tracking app and I can't decide between two database designs. The first has all the log entries in a single table, ie. TimeLog ------------- job_id : long timestamp start : boolean [or perhaps 'type : enum'] _id : long The other option is to have two tables, one for 'start' entries the other...

"Rebuttals" and "Comments" - Two DB-Tables or One?

I'm working on a project for a friend and I've come across a difficult decision. The project consists of essays, each of which can be challenged, and also commented on. The thing is this, only one person is able to challenge the essay, and then everybody else is locked out and can only comment. The rebuttals can only be two responses de...

Implementing A Ranking System

I've seen several question on how to secure and prevent abuse of ranking systems (like staring movies, products, etc) but nothing on actually implementing it. To simplify this question, security is not a concern to me, the people accessing this system are all trusted, and abuse of the ranking system if it were to happen is trivial and e...

UML modelling

hi guys! Am modelling student management system for a primary school. I wanted to know if there is any one out there ever modelled one(ERM, conceptual class diagram and deteailed class diagram) of that kind. it will also be very useful if i could get a site with those refference materials about UML Modelling. please help me out. ...

How can I enforce compound uniqueness in MySQL?

I have run into a situation where I want to ensure that a compound element of a table is unique. For example: Table ( id char(36) primary key, fieldA varChar(12) not null, fieldB varChar(36) not null ) I don't want fieldA and fieldB to be a compound primary key, since they change frequently, and 'id' is used as a reference thro...

PostgreSQL: Defining a primary key on a large database.

I am planing a database to store lots of text. (blog posts, news articles, etc.) The database needs to have the title, content (50k characters max), date, link and language fields. The same content can't occur on one link. Old content (older then 30 days, for example) will be deleted. Now, the problem is the primary key. I could just se...

Storing Array of Floats as a BLOB in Oracle

I am designing a new laboratory database. For some tests, I have several waveforms with ~10,000 data points acquired simultaneously. In the application (written in C), the waveforms are stored as an array of floats. I believe I would like to store each waveform as a BLOB. Questions: Can the data in a BLOB be structured in such a w...

Can you have relationships to system tables/views?

Is it possible to have a relationship from a user table to a system table view? To give context, I would like the values of a column in one of my tables to be restricted to the column names of another one of my tables, which seems easiest to do by going through the system view that houses the column names of the second table. So, using ...

How to keep copies of ordered items in a web shop?

People buy stuff in a web shop. I take their orders and save them to a database. For each ordered item, I need the quantity and the information about the item. At the very least, I'm going to need to save the current price and name of each item but I would really prefer to save everything. And here comes the question... What's the best...

Oracle - Is there any effects of not having a primary key on a table ?

We use sequence numbers for primary keys on the tables. There are some tables where we dont really use the primary key for any querying purpose. But, we have Indexes on other columns. These are non-unique indexes. The queries use these non-primary key columns in the WHERE conditions. So, I dont really see any benefit of having a primary...

When Would You Choose NOT to Use an Identity/Autonumber Field as Your Primary Key?

I don't believe in a Silver Bullet, but I really like to use sequences or autonumber identity columns as my primary key columns for database tables. They're unique, they index well, and I don't have to worry about null values. On the other hand, in some cases, they seem redundant when there are other unique columns in the table that co...

queries in Hibernate polymorphism

I'm relatively new to Hibernate and am trying to migrate a relatively simple existing database to something that I can use with Hibernate, and am looking for advice on how to structure my application. I have 3 types of entities: Item Category PropertyType Item and Category and PropertyType are all similar; they both have a name, des...