database

Can I check for constraints before a delete in SQL Server?

I have following situation. A main table and many other tables linked together with foreign keys. Now when I would like to delete a row in the main table a ConstraintsViolation will occur, which is intended and good. Now I want to be able to check if the ConstraintsViolation will occur before I trigger the delete row event. Is this po...

Identifiers in a one to many relationship

I have two tables, we'll call them Foo and Bar, with a one to many relationship where Foo is the parent of Bar. Foo's primary key is an integer automatically generated with a sequence. Since Bar is fully dependent on Foo how would I setup the primary key of Bar given the following constraints: Records for Bar are programatically gene...

Go Daddy SQL Server 2005 Remote Connection

Hi Guys, Is it possible to connect to my remote database hosted at godaddy from locally from my PC? And if yes how? I tried the connection string provided to me but it didn't work. Thanks ...

Identifiers in a Diamond Relationship between Tables

I have four tables (A,B,C,D) where A is the parent of one to many relationships with B and C. C and D are parents to a one to many relationship with table D. Conceptually, the primary keys of these tables could be: A: Aid B: Aid, bnum (with foreign key to A) C: Aid, cnum (with foreign key to A) D: Aid, bnum, cnum (with foreign keys ...

How do I track a repeating calendar event in C# / SQL Server?

I'd like to display a repeating event on a date/time display in an app. This date time display can take the form of a calendar, but it could also just be a list of upcoming events. What is the best way to handle tracking this event that can repeat? For example: Should the event be stored once in the database and projected out / r...

Catching events from an SSIS package loaded in C#

I have an SSIS package that executes several tasks. I manually added an event handler inside Business Intelligence Studio 2005 at the package level for the OnExecStatusChanged event. My question is, how can I add a handler for this event inside C#? I have loaded the package as pointed here and I also created a custom class inherited fro...

Where did Open Table go in SQL Server 2008?

As of SQL Server 2005, you used to be able to open a flat file in SQL Management Studio off the right click menu for any database table. Once opened, you could add or update records right there in the grid. Now that SQL Server 2008 is out, Microsoft has hidden that feature, at least from the right-click menu. Where did it go? ...

Twitter-like "follow user" and "watch this" problem

What's the best way to handle many-to-many trigger relationships like the Twitter "follow this user" problem. I have a similar problem with users "watching" threads for replies. If there are 10,000 users watching a thread, and someone replies, how best to notify the watchers? All I can think of is the following: Upon insert, check th...

Unaccounted for database size

I currently have a database that is 20GB in size. I've run a few scripts which show on each tables size (and other incredibly useful information such as index stuff) and the biggest table is 1.1 million records which takes up 150MB of data. We have less than 50 tables most of which take up less than 1MB of data. After looking at the siz...

Database Schema - Booking/Availability System

I was recently asked an interview question on a hypothetical web based booking system and how I would design the database schema to minimize duplication and maximize flexibility. The use case is that a admin would enter the availability of a property into the system. There could be multiple time period set. For example, 1st of April 200...

DAAB, the best approach to use Database instances is ...

Guys, I am going to use Enterprise Library (4.1) and especially DAAB. Here is I have questions: What is the best approach and why: Every time when I need to run a DbCommand I create Database instance using DatabaseFactory.CreateDatabase(); I have a base class with instanced Database (using the same CreateDatabase() static method) and...

Hibernate: How to make Hibernate delete records from child table when deleting parent if child is linked to parent with many-to-one?

Lets say I have two tables - "child" and "parent" with many-to-one relation. What I need is to delete child entries if parent record is deleted. It is not a problem if I link child table from parent by creating one-to-many association in parent.hbm and set cascade="all-delete-orphan". The problem is I don't want one-to-many relation o...

Best way to retrieve hierarchical data from database

I have to store blog style comments in a database. Each comment can have a parent one. I am doing it with a column called "parentComment" that has a null value when it is a top level comment or have a value if it is a response to another comment. What is the most efficient way to retrieve a comment and all its childs? ...

Database data upload design question

I'm looking for some design help here. I'm doing work for a client that requires me to store data about their tens of thousands of employees. The data is being given to me in Excel spreadsheets, one for each city/country in which they have offices. I have a database that contains a spreadsheets table and a data table. The data tabl...

Using a web service to secure a database.

There are some rumors floating around that the team at my company will soon be using web services for all future application development. The architecture is supposed to be something like this: Application --> Web Service --> Database The stated reasoning behind it is security. This sounds like a huge waste of time for little if any ...

Are nested intervals a viable solution to nested set (modified pre-order traversal) RDBMS performance degredation?

Among the known limitations of Joe Celko's nested sets (modified pre-order traversal) is marked degredation in performance as the tree grows to a large size. Vadim Tropashko proposed nested intervals, and provides examples and theory explanation in this paper: http://arxiv.org/html/cs.DB/0401014 Is this a viable solution, are there any...

Setting connection with function

Hey, I am trying to use ASP to create a connection to my database and i have the following connection code: Set objConn = ConnectDB() Set objRS = objConn.Execute(query) I have an include file that I have at the top of my page: <!--#include FILE=dbcano.inc--> And I get this error when I call my page: Microsoft VBScript runtime...

Good database client (MS SQL Server) with auto-complete, small memory foot-print and free?

Hi, Any sugestions? Currently I'm using Squirell but it consumes quiet a bit of memory... I just use the sql client to run some queries and get the result but i absolutely need auto-complete of tables, columns, etc ...

Populate TreeView from DataBase

Hi, I have a database table (named Topics) which includes these fields : topicId name parentId and by using them I wanna populate a TreeView in c#. How can I do that ? Thanks in advance... ...

Techniques for data comparison between different schemas

Are there techniques for comparing the same data stored in different schemas? The situation is something like this. If I have a db with schema A and it stores data for a feature in say, 5 tables. Schema A -> Schema B is done during an upgrade process. During the upgrade process some transformation logic is applied and the data is stored ...