database

[C#] NHibernate- Prevent deletion on a particular entity (i.e. make read-only)

Hi all How can I prevent NHibernate from deleting a single entity of a specific class? A programmatic way I am using at the moment entails checking for the entity's unique field "Name". Here's the scenario: I have a person and a group. The group can have persons and other groups. If the group named "Admins" is attempted to be deleted, ...

What is the current way in which I can add an object to the database using Zend Framework?

I want to save an object or form to the database. Only I can't find the easiest (or normal) way for how to do this. I found a lot of tutorials, but none seem to be easy or current. Can someone please help me with this? I use version 1.9.3 of the Zend Framework. ...

Does allowing a category to have multiple parents make sense? Are there alternatives?

Short question: How should product categories that appear under multiple categories be managed? Is it a bad practice to do so at all? Background info: We have a product database with categories likes this: Products -Arts and Crafts Supplies -Glue -Paper Clips -Construction Paper -Office Supplies -Glue -Paper ...

Database based Priority Queue

Hi, does anyone know of a good database based Priority Queue implementation? I'm dealing with large amounts of data so keeping it all in memory is unfeasible. Thanks! ...

How to backup a Firebird database ?

I am working on my first WinForms application with a Firebird database shared over a network. Now I wonder how should I ensure database backup and restoring? Up till now, my applications used embedded databases (SQLite), so I was sure that only my application accessed the database. The application itself was responsible for the backups ...

Where should database queries live?

Should queries live inside the classes that need the data? Should queries live in stored procedures in the database so that they are reusable? In the first situation, changing your queries won't affect other people (either other code or people generating reports, etc). In the second, the queries are reusable by many and only exist in o...

atomic compare and swap in a database

Hello: I am working on a work queueing solution. I want to query a given row in the database, where a status column has a specific value, modify that value and return the row, and I want to do it atomically, so that no other query will see it: begin transaction select * from table where pk = x and status = y update table set status ...

How should I create this customized e-commerce database model?

I am building an e-commerce website from scratch and have to make a special product configuration page. It's only 1 type of product, but it is configurable on several levels: Color (about 4 different options). Value is a VARCHAR. Material (about 10 different options). Value is a VARCHAR. Size (About 30 different options). Has 2 Val...

Strange problem connecting to a database from a published ASP.NET application

Hi. I'm developing an ASP.NET application that is connecting to a SQL Server database using a sql account ie a connection string in the format "Server=THESQLSERVER;Database=theDb;UID=guest;PWD=guest;". Everything works fine in the development environment in Visual Studio. However when I publish the application to my IIS (v5.0) webserver ...

Can you create a generic script that is not a stored procedure?

I have some experience with SQL Server 2005 and have written many scripts that just have a BEGIN statement and an END. I could use logic such as loops, cursors, etc. However I can not seem to be able to do this in MySQL without creating a stored procedure. I know that stored procs in MySQL are new and might not be as robust as that of SQ...

Grails multi column indexes

Can someone explain how to define multi column indexes in Grails? The documentation is at best sparse. This for example does not seem to work at all: http://grails.org/GORM+Index+definitions I've had some luck with this, but the results seems random at best. Definitions that works in one domain class does not when applied to another (w...

How would this lookup table example work?

Say I have a products table that stores off the shelf products that are not customizable and have static pricing. I also have 1 product in this same table that is customizable and it's price and all sorts of characteristics vary based on the configuration. The final price for this customizable product is based on an equation, not a sum...

Is storing counts of database record redundant?

I'm using Rails and MySQL, and have an efficiency question based on row counting. I have a Project model that has_many :donations. I want to count the number of unique donors for a project. Is having a field in the projects table called num_donors, and incrementing it when a new donor is created a good idea? Or is something like @num...

Search Database - ASP.NET MVC C#

I'm attempting to implement complete search functionality in my ASP.NET MVC (C#, Linq-to-Sql) website. The site consists of about 3-4 tables that have about 1-2 columns that I want to search. This is what I have so far: public List<SearchResult> Search(string Keywords) { string[] split = Keywords.Split(new char[] { ' '...

Quotes and double quotes always escaped when retrieve from table? How can I fix this?

Hi guys, I'm using the Zend framework here - I've noticed that for some reason the information is automatically escaped when it goes into the database - it doesn't do so on my localhost but it escapes automatically on my host. And when data is retrieved its not unescaped so something like 'Chris O'Donnel' goes in as Christ O\' Donnel and...

Store 2-dim table of attendance in database?

heya, We have a web-based application, backed by a MySQL database. One part of the system that we're coding requires us to store attendance (i.e. yes/no) to sessions for users for each day of a week. For example, we'd need to store Monday through to Friday, then for each day, morning, lunch, afternoon, evening sessions etc. So essentia...

How do I insert information in a SQL table if the table has a foreign key in it?

Say I have a user table with the fields: Name, Email, Telephone, IDCareer In this table IDCareer is the foreign key. I have another table called Career with the fields: IDCareer, CareerName My plan it to have a ComboBox on my form and pulls a list of available careers directly from my DB. My problem is this is my first time using SQL ...

Most Efficient Way to... Unique Random String

I need to efficently insert a 5 character RANDOM string into a database while also ensuring that it is UNIQUE. Generating the random string is not the problem, but currently what I am doing is generating the string and then checking the DB if it exists already... if it does, I start over. Is there a more efficient way to do this proces...

How to Store Passwords in Databases and Cookies (PHP/MySQL)

Hi, Having read this article and many others out there on how to not store passwords in databases and cookies, I'm wondering now how I should do it... What I've come up so far (after reading around a bit) is taking the clear-text user password, padding it with salt till it fills up 512 bits (64 bytes => 64 chars, since the page is non-...

Why are overflow blocks in a database not binary searchable?

This is related to primary database indexing mechanism (sparse indexing). Binary search can be used on the index file to locate an entry. But, if overflow blocks have been used, binary search will not be possible. Could someone explain how overflow blocks make binary search not possible to use? ...