database-design

Formatting Database Schema From SQL Server

Ok I ve been asked to generate a schema for a database that contains 20+ tables I ve used SQLServer Management studio to extract out the database schema but cannot export it into word If I copy it as a diagram the tables are too small Does anyone know how to extract the schema from a sql server database so that it is presentable to a ...

How to perform INSERT/UPDATE to Linking (Join) table which has FKs to IDENTITY PKs

I am new to designing my own database. My project is orders/products/inventory type data, using SQL Server 2005. During my reading I came across several customer/order type of examples, and I decided to use linking-table (sometimes here called junction, or join table) for my Order_Details since I had many-to-many relationships between OR...

How to load a one-to-many relationship in Data Mapper?

While I'll go for the Ghost pattern in a 1:1 relationship, I'm not sure if this is sufficient in a 1:n relationship. For example, when I load an Order object that may have a hundred Item objects, I would first assign NULL to the items property. The question is: A) Should I assign NULL and then, upon first access of the items property...

nhibernate help mapping entity with multiple foreign keys

Hi, how would I map this relationship in NHibernate (I'm using the simple idea of the auction example to demonstrate the problem) Database Tables / Entities: User - contains the users Item - an item for sale (like ebay) Bid - records a user's bid on an item I was imagining the bid table to look like this with: Id (PK), ItemId (FK), Us...

Key problem: Which key strategy should I use in my database?

Problem: When I use an auto-incrementing primary key in my database, this happens all the time: I want to store an Order with 10 Items. The ordered Items belong to the Order. So I store the order, ask the database for the last inserted id (which is dangerous when it comes to concurrency, right?), and then store the 10 Items with the for...

How to solve the A/B key problem?

I have a table my_table with these fields: id_a, id_b. So this table basically can reference either an row from table_a with id_a, or an row from table_b with id_b. If I reference a row from table_a, id_b is NULL. If I reference a row from table_b, id_a is NULL. Currently I feel this is my only/best option I have, so in my table (which ...

Database Headaches - Mind not working today

I cant seem to get my head around how to create this Each Bold Letter is a Database Table I need this to work with Entity Framework Product [ Product belongs to one group] Product Group - [Computer] [many to many] [Group has many items] [Product belongs to one Group Item] Product Group Item - [Hard Drive] [many to many] [Group Ite...

Is there an answer matrix I can use to decide if I need a foreign key or not?

For example, I have a table that stores classes, and a table that stores class_attributes. class_attributes has a class_attribute_id and a class_id, while classes has a class_id. I'd guess if a dataset is "a solely child of" or "belongs solely to" or "is solely owned by", then I need a FK to identify the parent. Without class_id in the ...

How to support Multi-Languages approach in DataBase Schema ?

Hi, I want my database to support multi Languages for all text values in its tables. So what is the best approach to do that?. Edit1:: E.G. I've this "Person" table: ID int FirstName nvarchar(20) LastName nvarchar(20) Notes nvarchar(max) BirthDate date ........... So if i want my program to support new language "...

Is it a good idea to incorporate a Reference Count into every database table?

From Objective-C i'm used to Reference Counting / Retain Counting (same thing). I love this concept, and it's plain simple. So I thought, why not apply this to a database? The problem is: Imagine these tables: users, photos. A user can own a photo, a user can like a photo of himself or someone else, and a user can recommend a photo. In...

What should every developer know about databases?

Whether we like it or not, many if not most of us developers either regularly work with databases or may have to work with one someday. And considering the amount of misuse and abuse in the wild, and the volume of database-related questions that come up every day, it's fair to say that there are certain concepts that developers should k...

How normal should my checkbox data be for storage in database

I have a web form with about 15 checkboxes that users may check 0 or all 15 checkboxes and any quantity in between. The database that will store the form data is MySQL, but reports will be generated from the data in MS Access using a MySQL ODBC connection. I see three options for handling this. The Spreadsheet way: Have one table wit...

High-Performance Hierarchical Text Search

I'm now in the final stages of upgrading the hierarchy design in a major transactional system, and I have been staring for a while at this 150-line query (which I'll spare you all the tedium of reading) and thinking that there has got to be a better way. A quick summary of the question is as follows: How would you implement a hierarchi...

Open source or free software for flow-chart and database-table connection visualisation?

Hi, I would like to ask you to tell me, what visualisation software to take. Normally I would use a vector illustation software like "inkscape", but I would like to use a software, where I don't have to draw the lines manually and where I can use the symbols withouth drawing them by myself :) so, do you know good software, that I can t...

Database Relationship in JSP like Ruby-on-Rails

In ruby on rails we can specify many Database relations line belongs_to, has_many, and this make coding a lot simpler. But is there any such database relationship APIs that brings such coding ease to JSP. I'm pretty new to JSP. But you can relate any code with ROR. ...

Number of times an entity is viewed

How do you track the number of times a particular entity (say a user profile much similar to stackoverflow.com) is viewed by other users? Would it make sense to update this information when an entity is viewed using a lifecycle event like PostLoad. Where would you store the number of times the entity has been viewed, would it be in the ...

How would I optimize this database design?

I am creating an application which generates statistical information for a pupil's performance over their school career. To achieve this, I need to store every grade ever attained by a pupil. But I have no idea how to optimally store this information. This is a preliminary design, but don't know how it will hold up in practice. So ea...

Data Warehouse Considerations: When and Why?

A little background here: I know what a data warehouse is, more or less. I've read several dozen guides on data warehousing, I've played with SSAS, I know what a star schema and a dimension table and a fact table is, I know what ETL is and how to do it. This is not a "how" question or a request for tutorials. My issue is that all of ...

Use raw SQL to create tables in SQLAlchemy, after which use ORM

Hello everybody Is it possible to use raw SQL rather than the TABLE construct for creating tables in SQL Alchemy? I would still like to use the rest of SQLAlchemy though, such as the object mapper and session module. I'm just not fond of the SQLAlchemy syntax used to create tables (I've spent too long mired in SAS and SQL to learn ano...

is_dirty VS last_modified_date in a db?

I am designing my database so i can do incremental backups. I am thinking there should be a weekly cron job that dumps data in a read only tar.bz2 and can dump most of my data easily since its had a modified date or is insert only. However there are some things like user_profile which holds the password and signature. How should i know w...