relational-database

What is the corrrect way to increment a field making up part of a composit key

I have a bunch of tables whose primary key is made up of the foreign keys of other tables (Composite key). Therefore the attributes (as a very cut down version) might look like this, please note that I am only showing the attributes that make up the key - there would be and are other attributes that are stored alongside the composite ke...

What is the best practise for relational database tables in mysql?

Hi, I know, there is a lot of info on mysql out there. But I was not really able to find an answer to this specific and actually simple question: Let's say I have two tables: USERS (with many fields, e.g. name, street, email, etc.) and GROUPS (also with many fields) The relation is (I guess?) 1:n, that is ONE user can be a member of...

What are the reasons *not* to use a GUID for a primary key?

Whenever I design a database I automatically start with an auto-generating GUID primary key for each of my tables (excepting look-up tables) I know I'll never lose sleep over duplicate keys, merging tables, etc. To me it just makes sense philosophically that any given record should be unique across all domains, and that that uniqueness...

In a One to One relationship should i drop one of the table's id column?

I have the following 2 tables in MySQL: Customer(Id, Firstname, Lastname...) Bonus(Id, CustomerId, Value, ...) The relation is One-To-One, every customer has only one bonus.(the CustomerId is unique in the Bonus Table) Q: Should I drop the Id column of the Bonus table? (I want to know why or why not) ...

Buddy List: Relational Database Table Design

So, the modern concept of the buddy list: Let's say we have a table called Person. Now, that Person needs to have many buddies (of which each buddy is also in the person class). The most obvious way to construct a relationship would be through a join table. i.e. buddyID person1_id person2_id 0 1 2 1 3 ...

What are Storage Engines in Relational databases ?

Hi, Can anybody tell me what are the storage engines with respect to relational databases ? ...

Strategy to structure a search index in a relational database

I am interested in suggestions for building an efficient and robust structure for indexing products in a new database I am building (i'm using MySql) When a product is entered through the form there are three parts I am interested in indexing for searching purposes. The product title The product description Tags The most important ...

Options for eliminating NULLable columns from a DB model (in order to avoid SQL's three-valued logic)?

Some while ago, I've been reading through the book SQL and Relational Theory by C. J. Date. The author is well-known for criticising SQL's three-valued logic (3VL).1) The author makes some strong points about why 3VL should be avoided in SQL, however he doesn't outline how a database model would look like if nullable columns weren't all...

CSV to DataMapper Import

This is probably very simple, but I'm quite new to ruby and active record. I've got a CSV dump of a database which I'm trying to import to a database using DataMapper. I'm having trouble understanding which type of relationships I should define in the models so that it matches what is defined CSV. Here's what data I've got from the CS...

Can I index my database table, and if so, how?

Is it better way to index a table ? ...

Usage / handling of non relational datasources in .NET applications

Which .NET (data / middel-tier) technologies / framworks can / should be be used, if the datasource isn't a classical relational database, but a service or a remote function call or whatever ? Are technologies like WCF RIA services or WCF DATA services (OData) suitable for handling non relational datasources. ...

Alternate names for a surrogate key/sequence number/ID column

I have a legacy table that has as a part of its natural key a column named <table_name>_IDENTIFIER and it seems like it would be confusing to create a surrogate key named <table_name>_ID or ID so I'm leaning towards naming it SURROGATE_KEY. All my other tables use the <table_name>_ID syntax. Any better suggestions? ...

Reading info from sqlite database, Syntax? How do I use it in html5 webapp?

I have a webapp that I'm building, and have just started with SQLite. I have been able to create my form, open the database I created, create the table, and fields i need, and enter data into the fields. Now I'm trying to read the data back out with a SELECT statement, to show it on screen and as a list of the columns. I just don't ...

how are viewing permissions usually implemented in a relational database?

What's the standard relational database idiom for setting permissions for items? Answers should be general; however, they should be able to be applied to example below. Anything flies: adding columns, adding another table—whatever as long as it works well. Application / Example Assume the Twitter database is extremely simple: we have ...

Relational database Design- Relationship problem

Hi I need to create database tables to store memo. in the "To" clause user may select individual employee or group of employees (Different groups are already available in database having many to many relationship with employee). i am wondering what should be structure of tables. For simple memo where there are no groups i will have "Memo...

db indexes application - best practice

When developing large systems (hundreds of tables) Do you create the indexes (and to lesser extend the other constraints in the DB) when you create the entities (tables), or wait for the system to be running (may be private Beta) to decide where to put the indexes? ...

MySQL: Two n:1 relations, but not both at once

Sorry for the title, it's difficult to explain. I need a data model similar to this: As you can see, a set can belong to both a user or a school. My problem: It should only be allowed to belong either to a user OR a school. But never both at the same time. How can I solve this problem? ...

Is it better to model databases after their applications, or after their components?

I'm structuring a database, and found that I have two different objects I'm trying to model. Each one consists of the same things (a varchar and a couple of foreign keys), and will do so for the forseeable future. I'm (as of now) going to put them in the same table, with an extra 'type' field, but I was wondering if there's standard pr...

Database design: Is there a way to improve on this design?

Simple question- Below is the database design to hold the following records account TransactionType TransactionName Amount FeeTransactionId TransactionId RefTransactionId Alex [Deposit from] [Credit Card x-1234] [-100.00] b a Alex [Deposit from] ...

What's the best way to organize data on my tiny embedded system?

I haven't done much programming for Embedded Systems before, and now I have to create some scripts for something relatively tiny (<60MB RAM, almost all of which is already used by other more critical processes, the processor is less ~ 500MHz). I can't run something that is on all the time, so Firebird is out. I suggested sqllite, but peo...