database-design

PHP/MySQL Structuring a Table/Database for Profile Usage

Hello all, I am looking for some direction on how the most efficient way to structure my database for users on my website. Essentially, I already have a "tblusers" database that includes basic biographical information, such as: tblusers: UsrID, First, Last, DOB, Phone Number, etc. However, one aspect of my website include...

Database naming of columns with PII and sensitive information

I am working with database tables that contains PII and sensitive information. Some of the data is PII and company sensitive information. The design document may not always be available to the developer especially when the data is being exposed by a view outside of the database (Oracle database link) to another program. Is there good n...

Stored Procedures vs No Stored Procedures - Security Viewpoint

For a web application database, from a security standpoint only, what are arguments counter to the point for an sp only solution where the app db account has no rights to tables and views and only exec on sps? If someone intercepts the app db account, the surface area exposed to an attack is much less then when tables and views aren't e...

How to store a vector of time/value data in a database

I'm gathering a vector of time/value pairs, in this case I/O latency versus time for a server. I'd like to store them in a MySQL database that is queryable by date, server and other metadata. Examples: I want be able to query the I/O latencies from 1:00 PM to 3:00 PM for the server Atriedes on August 19th, 2007. I want to also be able...

Database Design for an Electronic Notebook

I have a question about database design. I want to create an electronic notebook or "Everything Bucket" for my own education. I know there are great alternatives out there like EverNote or Circus Ponies Notebook, or the open source KeepNotes or Red Notebook. But, like I said, I want to create my own just for the learning experience. I d...

Membership products data schema

I'm trying to model my organization's membership products for accepting and recording membership purchases in our business database. Someday we hope the purchases will be made online and automatically put into the business database. The problem is that our membership products are all over the place. We have 4 types of organizations th...

Is there a need of namespaces in database?

Often I am frustrated by the fact that there are a lot of tables, views, stored procedure all placed under one hierarchy. I am looking for a way (like namespaces) that would group related tables under one banner. This would not only be easy to understand. Also i would avoid the need for coming up with fancy names. I am not aware of any p...

database logical problem

good day, database programming and logical problem. for instance: i got 3 tables. table 'Companies', table 'Branches' and table 'departments' from companies table (Primary), linked by company code to enter the branch table, the branch has many department linked by branch code to department table. the problem comes when 1 branch in ...

in general, should every table in a database have an identity field to use as a PK?

This seems like a duplicate even as I ask it, but I searched and didn't find it. It seems like a good question for SO -- even though I'm sure I can find it on many blogs etc. out there. SO will have more of a debate than you can get on a blog. I'm running into an issue with a join: getting back too many records. I think of this as "exp...

Using Scripts to Ensure Data Integrity in Oracle

Is it bad practice to use triggers or scripts to maintain data integrity that Oracle is not designed to enforce, or is this a sign I'm modeling my data in a poor way? From responses to a previous post (Implementing User Defined Fields), I have decided that I want to move forward designing with a mix of Class and Concrete Inheritance. I...

SQL Design - Accounting for unknown values

Ok, this gets a little tricky. Here goes. Say I have a table called HoursCharged ChrgNum(varchar(10)) CategoryID(uniqueidentifier) Month(datetime) Hours(int) CategoryID is a foreign key reference to another table in my database, which is just a name/ID pairing. ChrgNum is guaranteed to be unique outside of this database, a...

Storing enumerated constants in the database

Possible Duplicates: Should I store Enum ID/values in the db or a C# enumeration? Persisting Enums in database tables Quick and easy question which will probably be fodder for discussion: Let's say my application has an enum with 2-3 values which are basically never going to change. Do you think those should be represented i...

Design database structure to store weekly chart positions?

Suppose to have something like: Top 10 Products (WK 51) Product1 Product2 ... Product9 What can be a good database structure to store weekly charts that allow easy post-processing analysis like a graph of chart positions for a certain productID? ...

Saving Group of Persons and every change in it

I have this situation were I need to include Persons inside a Group. For that, I create a relation like the one showed in the image. The groups are constantly changing (several times a day, several persons are added and removed from a group). I need to save the status of the group everytime it changes (which persons were in it and bet...

mysql query speed

I just want to ask which out of the two ways of storing data would give my better results A. Storing data in a single table with over 20+ columns OR B. Distributing the data into two tables of 15 and 6 columns each one more thing, even if I distribute the data I still might have to access both the tables at the same time in 60% of c...

Most efficient way to store a 20 Meg file in a SQL Server 2005 IMAGE Column

We store documents in an SQL Server 2005 database table with a column format of "Image". Every time I try to store a PDF file which is greater than 1 Meg, it somehow gets corrupted. Is there any particularly efficient method in .NET to serialize and store large files (~10megs) into a database? [Edit] Microsoft actually says the max f...

What are the benefits of putting a default value in a column?

If this question is too broad, my apologies. I am a DBA and I am working with a developer that thinks column defaults are a bad idea and that just setting the column to disallow nulls is good enough. I am looking for the benefits of column defaults from the developers point of view. Thank you for your comments. ...

Can anyone explain to me how the HABTM principle works?

Can anyone explain to me how the (HABTM or many to many) "has and belongs to many" principle works? Say I have a users table and books table and then I have a table users_books where the IDs are. When would I need to actually use this principle and how would it work? ...

Normalize or Denormalize in high traffic websites

what is the best practice for database design for high traffic websites like this one stackoverflow? should one must use normalize database for record keeping or normalized technique or combination of both? is it sensible to design normalize database as main database for record keeping to reduce redundancy and at the same time maintain...

Is there a good reason I see VARCHAR(255) used so often (as opposed to another length)?

In multiple courses, books, and jobs, I have seen text fields defined as VARCHAR(255) as kind of the default for "shortish" text. Is there any good reason that a length of 255 is chosen so often, other than being a nice round number? Is it a holdout from some time in the past when there was a good reason (whether or not it applies toda...