database-design

date representation in user interface

Most of the sites capture the date (e.g. birth date) information as either a single entity (i.e via a calendar control) or instead as separate fields (date, month, year). Are there any benefits in showing them as separate fields? Are they represented in the database as DATE data type or as separate fields. I am just trying to under...

postgresql: foreign key to either tableA or tableB

I'm trying to figure out how to define the schema of a database on with Postgresql 8. I have 2 tables: Journals, Books that define the publications I have Journal: id_j, name, issn, other fields Book: id_b, name, isbn, author, other fields and I have another table Scans that logically refers both the previous tables. Scans: id, m...

CoreData Relationships Synchronized with a Traditional Database

I have an existing database schema that is used in both an online (MySQL) and desktop (SQLLite) version of my product (data is synchronized between the two). I am now developing an iPhone version (CoreData) that I hope to synchronize with one or both of the existing products, but I am having trouble deciding how to manage entity relation...

How to create a "facade" table?

A legacy database contains a join table which links tables table1 and table2, and contains just two foreign keys: TABLE_ORIG: table1_id table2_id In order to utilize this table using JPA I would need to create a surrogate primary key to the link table. However, the existing table must not be modified at all. I would like to create an...

Database design and foreign keys: Where should they be added in related tables?

I have a relatively simple subset of tables in my database for tracking something called sessions. These are academic sessions (think offerings of a particular program). The tables to represent a sessions information are: sessions session_terms session_subjects session_mark_item_info session_marks All of these tabl...

add schema to path in postgresql

I'm the process of moving applications over from all in the public schema to each having their own schema. for each application, I have a small script that will create the schema and then create the tables,functions,etc... to that schema. Is there anyway to automatically add a newly created schema to the search_path? Currently, the on...

Should I use a huge composite primary key or just a unique id?

I have been trying to do web scraping of a particular site and storing the results in a database. My original assumptions about the data allowed a schema where I could use fairly reasonable composite primary keys (usually containing only 2 or 3 fields) but as time went on, I realized that my original assumptions about the data were wron...

Designing a database for a user/points system? (in Django)

First of all, sorry if this isn't an appropriate question for StackOverflow. I've tried to make it as generalisable as possible. I want to create a database (MySQL, site running Django) that has users, who can be allocated a certain number of points for various types of action - it's a collaborative game. My requirements are to obtain:...

Multiple Tables or Multiple Schema

http://stackoverflow.com/questions/1152405/postgresql-is-better-using-multiple-databases-with-1-schema-each-or-1-database I am new in schema concept for PostgreSQL. For the above mentioned scenario, I was wondering Why don't we use a single database (with default schema named public) Why don't we have a single table, to store multipl...

Is any tool can help create/fix a table into normal form?

Hi,I know the importance of being normal in database design. But many people always lives with broken windows. Is any tool can help create/fix a table to normal form? I mean to force developer create table in normal form, or help to check if the table being normal base on existed data within the table. Thanks…… ...

How to overcome shortcomings in reporting from EAV database?

The major shortcomings with Entity-Attribute-Value database designs in SQL all seem to be related to being able to query and report on the data efficiently and quickly. Most of the information I read on the subject warn against implementing EAV due to these problems and the commonality of querying/reporting for almost all applications. ...

how to make Toad data modeler connect to my existing SQL server 2008 express?

Just installed Toad Data Modeler freeware and try to make a connection with my SQL Server Express 2008. Don't know how to do it. Anywhere has step by step instructions about how to connect a design tool to a database in Window? In the Data Source, do I need to define one for SQL Server? ...

how to guarantee atomicity across two databases (the filesystem and your RDBMS)?

i am working on a online file management project.In which we are storing references on the database(sql server) and files data on the on file system;.In which we are facing a problem of coordination between file system and database while we are uploading a file and also in case of deleting a file that first we create a reference in the d...

Looking for some Feedback on a DB Design

I'm currently working on a ticketing system which allows our users to submit tickets based on their own needs. i.e. if Department "A" is submitting a ticket they can have certain types of problem categories (such as "Supplies" or "Printer") along with details pertaining to the chosen category. I have laid out a partial db design and i wa...

Table design issues - should I create separate fields or store as a blob

Hi guys I'm working on my web based ordering system and we would like to maintain a kind of task history for each of our orders. A hsitory in the sense that we would like to maintain a log of who did what on an order like lets say an order has been entered - we would like to know if the order was acknowledged for an example. Or lets say ...

Is it OK to re-create many SQL connections (SQL 2008)

When performing many inserts into a database I would usually have code like this: using (var connection = new SqlConnection(connStr)) { connection.Open(); foreach (var item in items) { var cmd = new SqlCommand("INSERT ...") cmd.ExecuteNonQuery(); } } I now want to shard the database and therefore need to choose the c...

how to enforce multiple unique fields in database table

i have a table called Cars and the primary key of the table is 'id'. I also have a field called 'name'. I would like to make sure no one enters the same name twice even though it wont break my db integrity. what is the best way of doing this? ...

Design for tagging system in GAE-J

I need a simple tagging system in GAE-J. As I see it, the entity that is being tagged should have a collection of keys referring to the tags with which it's associated. A tag entity should simply contain the tag string itself, and a collection of keys pointing to the entities associated with the tag. When an entity's list of tags is...

How to properly design a simple favorites and blocked table?

Hey, i am currently writing a webapp in rails where users can mark items as favorites and also block them. I came up two ways and wondered which one is more common/better way. 1. Separate join tables Would it be wise to have 2 tables for this? Like: users_favorites - user_id - item_id users_blocked - user_id - item_id 2. s...

Model a Zero or One to Many Relationship

How should I model a zero or one to a many relationship in the database? For example, a user record may or may not have a parent. So should my user table have a t_user.parent_id or should I have an associative table called t_user_hierarchy with the columns t_user_hierarchy.parent_id and t_user_hierarchy.user_id? ...