database-structure

In a database, would you use a date field or year and month fields if you only need year and month?

I am setting up a table where I need the year and month. In MySQL I believe I have 2 options: (1) 2 fields: 1 for year, 1 for month or (2) a date field (the day would always be 1). The 2 fields has the advantage of being some what faster (I think) because MySQL doesn't have to convert the value from a date to an integer although this is...

PostgreSQL: best way to create new/duplicate existing tables every year

Hi guys, referring to this question, I've decided to duplicate the tables every year, creating tables with the data of the year, something like, for example: orders_2008 orders_2009 orders_2010 etc... Well, I know that probably the speed problem could be solved with just 2 tables for each element, like orders_history and order_actual,...

database model structure

Hi all, I have a column groups. Groups has different type stored in group_types (buyers, sellers, referee). Only when the group is of type buyer it has another type (more specialized) like electrical and mechanical. I'm a bit puzzled with how I will store this in a database. Someone can suggest me a database structure? thanks ...

Database Structure viewer/printing

I have an SQL Server database, with over 60 tables in it. This database has plenty of relationships between these tables and while it's normalized, it's still complex to use because of the huge number of tables. There are, of course, many tools that can show the database structure in some diagram. SQL Server itself is even able to creat...

Database slow retriving/updating/inserting problem with more than 5mil records in each table

How to structure database to avoid slowdowns? (Engine: MyISAM) Currently i have database with more than 5milion records in one table that causes slow data retrieving. I'm currently searching for ways to structure database to avoid this kinds of database. (Database Engine MyISAM) Tables that cause problems are posts and comments having ...

Hierarchical Database, multiple tables or column with parent id?

Hi, I need to store info about county, municipality and city in Norway in a mysql database. They are related in a hierarchical manner (a city belongs to a municipality which again belongs to a county). Is it best to store this as three different tables and reference by foreign key, or should I store them in one table and relate them w...

SQLAlchemy - relationship limited on more than just the foreign key

I have a wiki db layout with Page and Revisions. Each Revision has a page_id referencing the Page, a page relationship to the referenced page; each Page has a all_revisions relationship to all its revisions. So far so common. But I want to implement different epochs for the pages: If a page was deleted and is recreated, the new revision...