database-design

Maintaining Integrity

Suppose I have two tables 1st table emp EmpID | EmpName|xyz...coloums 1. | Hrishi | 2. | Nikhil | 3. | Hrishi | 2nd Table Department DeptId |EmpId |Deptname....Xyz coloum 1. |1 |computer There is a one-to-many relation between emp and department table. Now I want to call a stored procedure where empName wil...

Database design - exposing Primary Key

Hello Imagine that I have a Customer table. And in this table is an ID column, Primary Key int, Identity, all that jazz. Our Customer also has a Name. Now, if I was to send out information in a report, or an e-mail blast, where there was a link back into my website to uniquely identify that Customer, would it be good practice to use ...

Adding an ad to a mysql database; Point me in the right direction please...

Currently, I have an 'add your ad here' page, with a form. Now, the user must select what category he will want to post an ad into... So I have a table for each category in mysql. Now my question, how would I make each ad unique, with an ID nr? If I have several tables, the 'auto increment' might turn out to be the same in some ads, a...

Complex Queries using GAE datastore

Hi. I am in the early stages of developing a sports statistics website (ultimate frisbee) and would like to know your opinions if Google App Engine is right for me. I am writing it in Python using Django and have been comfortable with standard RDBMS for years but this site is a long term project and I am expecting very large amounts of ...

Create a database for scalability

How do i create a database for scalability? I am in the middle of http://www.slideshare.net/vishnu/livejournals-backend-a-history-of-scaling which i cant read ATM and need to leave. But i would like to know more about creating a database that scales well. Somethings that it mentioned and occur in my mind are Separate handles for reads ...

3NF Database Normalization

There is a report table for overdue DVD rentals. The store has multiple copies of the same DVD (they are all numbered to be identified). How can I normalize this data to meet 3NF requirements? ...

What is best: several tables or a really big one?

I was wondering about this. Let's say I need to store in a datawarehouse the data for several measures vs time: t | x' ------- 1 | 20 2 | 50 3 | 30 t | x'' ------- 3 | 23 4 | 56 6 | 28 and so on.. t | x''n ------- 5 | 35 6 | 92 7 | 23 If I need to build some large fact table composing the previous data in ways not yet...

When not to use surrogate primary keys?

I have several database tables that just contain a single column and very few rows, often just an ID of something defined in another system. These tables are then referenced with foreign keys from other tables. For example one table contains country codes (SE, DK, US etc). All values are always unique natural keys and they are used as p...

How to make session to allow different project?

I am planning to make a project management with PHP/MySQL/Codeigniter. It will have 10 - 20 users and 20 - 30 projects going on at the same time. Let's say John is a member of project A, B and C. Cindy is in A, D, F G etc. I want to make it only members of project can access the project. Now I am not sure how to approach this. Wha...

Does Microsoft Access 2003 contain sets or multisets?

I'm trying to confirm or deny whether you can define a table column in MS Access 2003 as a set. It seems this is implemented in Office 2007 - you can define a column to have a 'multi-select list' in the query/lookup, but this feature appears to be unique to the new access 2007 file format as far as I can determine. Worded another way, ...

Database Design - Four-Level Parent-Child Relationships

This might get a little complicated. Here goes. Say we have a parent-child relationship like this: A Project contains many Tasks. A Project may also have any number of Revisions. And the database schema for these tables look something like this: Projects: ProjectID ProjectName ProjectRevisions: ProjectRevID ProjectID ProjectRe...

is it good to have primary keys as Identity field

Hi , I have read a lot of articles about whether we should have primary keys that are identity columns, but I'm still confused. There are advantages of making columns are identity as it would give better performance in joins and provides data consistency. But there is a major drawback associated with identity ,i.e.When INSERT statement ...

Automatic filling entity properties

Hello everybody I have some type an architect(?) question I develop an application, based on Spring and Hibernate (annotated configuration) For each table in my database I added 4 fields: createdBy and modifiedBy(String), created and modified (Datetime). Respectively each entity class also has this fields and getter/setter pairs. So I...

Does Nested Sets model work with article with many categories (many-to-many)?

Hi guys, I've been using the adjacency model for hierarchical data for the longest time and was searching the internet for a more efficient way to traverse trees until I read about Nested Sets yesterday. I liked the idea but have a few doubts............. Now I just wanted to know if it is possible to use the Nested Sets model for many...

Nullable Foreign Key bad practice?

Let's say you have a table Orders with a foreign key to a Customer Id. Now, suppose you want to add an Order without a Customer Id, (whether that should be possible is another question) you would have to make the foreign key NULL... Is that bad practice or would you rather work with a link table between Orders and Customers? Although the...

MySQL Status Model -- Best Implementation?

So I'm working on a framework-esque system with one of my co-workers. Our current challenge is how to best implement statuses. Oftentimes, a status will carry with it unique data (a color for a table row, or text to be displayed to a user. etc). Currently, we have a statuses table which contains all this data. Contained in that table is ...

Entity Framework - Change Relationship Multiplicity

I have a table [User] and another table [Salesperson] in my database. [Salesperson] defines a unique UserID which maps to [User].UserID with a foreign key. When I generate the model with Entity Framework I get a 1-to-Many relationship between [User]-[Salesperson], meaning that each User has a "Collection of Salesperson", but what I want ...

Users need to create dynamic rules that apply to other users access to the group

Okay so here is "in a nutshell" what I'm trying to accomplish... Users of my application can go and create a new group. They can specify criteria about other users which they will allow/deny to determine who is allowed to join the group. Example: Age: 12 - 16 yrs old Height: 5 - 6 feet The data table that stores the rules would be li...

Database design question

How can a user be found using the following properties providing that user do not have any id Name Father's Name Mother's Name Date of Birth Sex Remember that user may make mistake while typing :( Please share your ideas.... ...

What T-SQL data type would you typically use for weight and length?

I am designing a table that has several fields that will be used to record weight and lengths. Examples would be: 5 kilograms and 50 grams would be stored as 5.050. 2 metres 25 centimetres would be stored as 2.25. What T-SQL data type would be best suited for these? Some calculation against these fields will be required but using a de...