database-design

Why so few full database schemas sample online?

It is a bit strange to me about database schemas sample which I think most of the projects will need to design a database for it. but when I try to find sample online, it is really rare (eg. full database schema for Inventory Management, School Management, HumanResource management). I know that each database design is depends on the proj...

Model a master template: Inherit or not?

I have a scenario which is not easy to explain, but I am sure it is a very common problem. I will try my best to illustrate the problem. Lets say we have a Survey application which allows us to create surveys. Each survey has its own structure (contains questions, questions are grouped and ordered, etc.). Those surveys are managed by an...

Character Column Lengths

What are some good rules of thumb for specifying a column length? People will arbitrarily use "VARCHAR(50)" for name fields etc... but most of this is guess work. Does anyone have any resources they use? What are the rules of thumb you follow to designate a character length? For example, for a URL - these can be lengthy especially given ...

Ms-Access MDB: Split Memo field into Several Text fields. (To prevent data corruption)

I use an Access database used just as back end. I use some Memo Fields. I have learnt that Memo Fields are subject to cause database corruption because they are stored in a separate data page; the record only holds a pointer to the data page where the actual data is stored. Most of the time I just need from 100 to 1000 chars or so, so ...

Accessing info from FK-related tables with LINQ

I am working on an employee-scheduling system. I think I have the database setup pretty well, and have run into a snag on pulling the data for my database and getting it onto the page. I am using LINQ to make things easy on myself. Here is the Object Relational Map. Here is my Linq select statement: protected void LinqSelecting(object...

What is the best way to create and maintain a movie database?

There are similar questions, but none answers what I really need. I actually don't want to create as long as there is already one ready-made. If so please guide me on the right direction. This isn't anything big, just to maintain my own collection. So basically: Is there a ready-made CMS (or a plugin for a CMS) that does this, even ...

Oracle XE or MySQL , which one I should choice?

I am going to develop a SNS website. Now I need to make a decision between Oracle XE and MySQL. I know you are a group of experts. Can you share some comments on this? Best wishes Ariso ...

How to insert a new record to table A when table A deppends on table B and vice versa

Hello, I'm not sure if this is well designed, if it's not please, advice me on how to do this. I'm using Sql Server 2008 I have: TableA (TableA_ID int identity PK, Value varchar(10), TableB_ID PK not null) TableB (TableB_ID int identity PK, Value varchar(10), TableA_ID PK not null) The goal is simple: TableA can have rows only i...

MySQL: How to get results of stored procedure inside a stored function?

Hello, I have a stored procedure that makes very complex joins and returns 1 row of data (LIMIT 1 is used). In my application I then use that data to make some calculations. This way I try to keep business logic out of stored procedures. But now I need to get that data in another stored function to also make some calculations. The reaso...

What's a good design for an intermediate triple-relation model?

Hello, I'm new to Rails and don't grasp yet all the possibilities with associations. Here's my problem: I have a couple of models like apple and lemon. Then there's the model 'relation' that holds triples of relations: subject | relation | object apple | is sweeter than | lemon The migration for 'relations' is this: create_table :...

Preferred database/webapp concurrency design when multiple users can edit the same data

I have a ASP.NET C# business webapp that is used internally. One issue we are running into as we've grown is that the original design did not account for concurrency checking - so now multiple users are accessing the same data and overwriting other users changes. So my question is - for webapps do people usually use a pessimistic or op...

How do I represent object classification hierarchy in a RDBMS

My data, IF it would be represented by objects, it would look like: abstract class A{ int a; int b; string c; } class B inherits A{ string D; } class C inherits A{ int e; int f; } My question: Do I create a separate table for entities B and C, Or do I create one main table, and for each entity type I do different joi...

What is the most efficient way to store and query trees?

I need to analyze 1 TB+ of web access logs, and in particular I need to analyze statistics relating to requested URLs and subsets of the URLs (child branches). If possible, I want the queries to be fast over small subsets of the data (e.g. 10 million requests). For example, given an access log with the following URLs being requested: /...

What's the best way to store/calculate user scores?

I am looking to design a database for a website where users will be able to gain points (reputation) for performing certain activities and am struggling with the database design. I am planning to keep records of the things a user does so they may have 25 points for an item they have submitted, 1 point each for 30 comments they have made...

Represent three way database functional dependency in 5th normal form

Is it possible to represent a composite key functional dependency of a non key column in fifth normal form? I have three tables, users ---------- id name events ---------- id name events_users --------------------------- id user_id event_id participation_type (ENUM) As I know, the 5th normal form needs the tables to be represented ...

Designing a action history database for different types of actions

In a bugtrackingsystem, I want to keep track of some actions. Actions like change status, add comment, change priority, and other actions. The problem is, how do I store those different actions, with different parameters. For example when someone changes status, it needs to save statuschange, with old status and new status. But when som...

Should each and every table have a primary key?

I'm creating a database table and I don't have a logical primary key assigned to it. So, I'm thinking about leaving it without a primary key, but I'm felling a bit guiltly about it. Should I? Should each and every table have a primary key? EDIT: Okay, okay... I've created the primary key! Are you happy now? :) ...

Does a table with a surrogate key require a unique constraint on a natural key to be in 1NF?

The pragmatists have won the argument of surrogate vs. natural primary keys in favor of surrogate keys*. In my own work I always use SQL Server identity columns without a second thought. But it occurs to me that, for a table to be in 1st normal form, I should be able to identify a natural key and enforce it with a unique constraint. I ca...

Open Office Base Datetime Default

Can anyone tell me how to set the default value on a date field in Open Office Base, in the same way that GetDate() works for SQL Server? Cheers OneSHOT ...

How generate diagram from SQL DDL?

For example DbVisualizer can be used to connect to a DB and create nice diagram out of existing tables and their relations. But in this specific case I do not have a live database but I have bunch of create table and alter statements. Is there any tool to generate similar diagrams out of SQL DDL? ...