database-design

Limiting character length in Sql Cell, significant difference to memory and performance?

Instead of using NVarchChar (max) for my field I am limiting the lengths arbitrarily. WHen does limiting these fields really make a significant difference in terms of performance? Every 100? 200? 1000 characters? ...

Database table with just 1 or 2 optional fields... split into multiple tables?

In a DB I'm designing, there's one fairly central table representing something that's been sold or is for sale. It distinguishes between personal sales (like eBay) and sales from a proper company. This means there is literally 1 or two fields which are not equally appropiate to both cases... for instance one field is only used in one cas...

Designing tables for storing various requirements and stats for multiplayer game

Original Question: Hello, I am creating very simple hobby project - browser based multiplayer game. I am stuck at designing tables for storing information about quest / skill requirements. For now, I designed my tables in following way: table user (basic information about users) table stat (variety of stats) table user_stats (conne...

Lifestream in Rails

I'm currently building a "Lifesteam" style website in Rails. A lifestream usually is an aggregate of public content (usually received via APIs). I'm currently confused about the database structure. There will be a Users table (as users will be able to sign up and have their own lifestream). I'm wondering whether I should also have a S...

SQL Server Database Schemas

I use schemas in my databases, but other than the security benefits and the fact that my OCD is happy, I don't really know whay it is good practice to use them. Besides the more granular security, are there other reasons for using schemas when building a database? ...

Examples of "when is good idea implement many-to-many relationships"?

I ask this because need to understand/explain better with examples. clasical examples like: an Article can be published in multiple Publication objects, and a Publication has multiple Article objects. (source) I see is usefull for web2.0 for sharing features. ...

what is more costly, 2 updates, or a delete and an insert?

For a certain piece of business logic, a sequence could be either two separate updates, or a delete followed by an insert. Basically, the update would nullify a column so I can make it seem like a delete. I am not concerned with losing rows (so a soft delete is not necessary): what is the more efficient approach? ...

Oracle Schema Doubt?

Currently am using postgres with diff schemas for diff modules.Now i am planning to switch towards oracle.But i heard that in oracle schema is not there..Is it true..if it is like that how can i migrate? ...

Good datamodelling software

I was wondering if anybody had recommendations for some good datamodelling software? I've used an older version of Sybase Powerdesigner and found it a bit clunky - was hoping to get something a little easier to use... ...

What is a "database entity" and what types of DBMS items are considered entities?

Is it things like tables? Or would it also include things like constraints, stored procedures, packages, etc.? I've looked around the internet, but finding elementary answers to elementary questions is sometimes a little difficult. ...

How to map one class against multiple tables with SQLAlchemy?

Lets say that I have a database structure with three tables that look like this: items - item_id - item_handle attributes - attribute_id - attribute_name item_attributes - item_attribute_id - item_id - attribute_id - attribute_value I would like to be able to do this in SQLAlchemy: item = Item('item1') item.foo = 'bar' ses...

What kind of return on investment is there in learning Set Theory, with respect to database design and query?

I am learning database right now -- and some of the queries are getting just plain crazy. I know that during query optimization you may sometimes rewrite queries in different ways to minimize certain things. I am looking at a correllated subquery example and see that it results in the same resultset as a LEFT JOIN. I am thinking that...

Should I design a table with a primary key of varchar or int?

I know this is subjective, but I'd like to know peoples opinions and hopefully some best practices that I can apply when designing sql server table structures. I personally feel that keying a table on a fixed (max) length varchar is a no-no, because it means having to also propogate the same fixed length across any other tables that use...

Modeling Yes/No Attributes in Database

I have a fairly common scenario where a user can select from a set of attributes. The attributes in the UI are represented by checkboxes. For example: Components: Harddrive(y/n), CPU(y/n), Monitor(y/n), Keyboard(y/n), etc.... In the past I have generally modeled this scenario like this: "PCs" 1:M "PC Components" M:1 "Components" A...

Database design to hold a person's information that changes with time?

We use a third-party product to manage our sports centre membership. We have several membership types (eg. junior, student, staff, community) and several membership statuses (eg. annual, active, inactive, suspended). Unfortunately the product only records a member's current membership type and status. I'd like to be able to track the way...

EmailAddress field length in database

Possible Duplicate: What is the optimal length for an email address in a database? What would you put as the length of an email address field? In the db I look after we have nvarchar(60) but this seems arbitrary. Is there a maximum length I can allow for or are email address lengths unbounded? EDIT this is a dupe of http://st...

Suggestion for database design - intensive insert and delete large amount of records

Hi, We have a database with a very simple schema: CREATE TABLE IF NOT EXISTS tblIndex( frame_type INT, pts VARCHAR(5), ts_start INT primary key, ts_end INT) And the application scenario is : Every second user will insert 2 ~ 50 records ,and the ts_start fields of those records is always increasing. After ...

MySQL Unique Indexes design

Thank you one and all for you're answers. I'm learning as I'm going - so I'm learning but still got a long ways to go. For work, we primarily use MySQL for our databases - web development. I have a question concerning unique indexes - when to use them properly and how. I'm sure pretty I understand their purpose - declare a column as a ...

How to store language tag IDs in databases, as smallint or varchar?

I'm wondering about how to store language tag IDs (e.g. en-US). A quick example: Table l10n ( l10n_id SMALLINT, code VARCHAR(5) ) PK: l10n_id Index on code Table product ( product_id INT, ..language-neutral columns.. ) PK: product_id Table product_l10n ( product_id INT, l10n_id SMALLINT, ..language-specific columns....

MySQL Create table with indexes error

Ok, so I am creating tables in MySQL with indexes and foreign keys. I use MySQL Workbench to create the tables and then have it forward engineer a SQL create script (I do better in a visual DB environment than just writing out the SQL code by hand right away). The problem is many times when I import the sql script into mysql, I get the ...