Showing posts with label design. Show all posts
Showing posts with label design. Show all posts

Sunday, March 25, 2012

Database for multiple clients

I have a SQL Server 2005 Express database that was designed to be used by one client. What is the best way to change the design so it can contain multiple clients that can only see data entered by users of each client organization?

Also I'm using the asp.net membership database to handle login and profiles. Can this be used with my multi client database?

Let's say you have TableA that contains data for one client. You intend to change the design to include data for multiple clients, where each client sees their own data.

Here are classic database design steps to follow in this situation

1. Create a reference table that holds the organization name and a unique ID for each organization - let's say that field is called organization_id

2. Add a record per organization to this table.

3. Add the field organization_id to TableA and set the value to 1 for all existing records

4. All future records added into TableA must have the correct organization_id value.

5. Create a View that restricts data in TableA to a specific organization_id.

6. Change your application to ensure that all data access is done via views that are restricted on organization_id

That's a kind of summary of what you're looking for. I repeat that using Views are the standard way of ensuring that clients only see their relevant data.

For your second question - certainly you may use login and profiles. I have implemented this kind of design by using Roles (aspnet_roles) as the reference table I mention in step 1 and 2. So you create a role per organization. Then add RoleID to your other tables as in step 3.

|||

Thank you very much for this information.

Is it possible to use my current aspnet_database as you mentioned, even if I already use roles for limiting user access to pages in the application? Also the application uses stored procedures to insert,update, and delete date.

Thanks again for your good thoughts,

|||

Yes, it's possible to use a current security database even if you already use roles. Users can be in more than one role. So keep your existing roles, and create additional roles for the organizations. Presumably all your current users are from one organization (your first), so add them into the correct new role - that won't effect the existing user access limits.

Great that the application uses stored procedures - that is already a sign of good design. There are several ways to incorporate multiple clients here. You could add a parameter to your stored procedures which accepts the correct RoleID and ensures that the new column is maintained correctly. Note that if your procedures already accept a UserID, then you don't have to change the parameter list - within the stored proc you can do a lookup of the correct RoleID.

Note that changing the stored procedure interface will need corresponding changes to all your client code - and regression testing. Another option depends on how your application connects to the database - if you are using a common login to the database for all users this is not an option, but if you are using user logins (individual logins and passwords for your users), then you can programmatically determine within the stored procedure who is logged in (using a system function) and then get the RoleID.

Good luck! By the way, if you extending the application for somebody else (your manager or a client), make sure they understand that changing from single to multiple clients is a significant change to an application - don't sell yourself short!

sql

Monday, March 19, 2012

Database Documentation

If someone can provide a good guideline for finding
Database centric documentation, which would include naming
convention, Design & Pattern, Process & Procedure and such.
This guide would be something like MSF, but with more
details in planning, implementation, development,
deployment, maintenance, and troubleshooting.
Thanks in advance.from the Operational side , there is some good stuff in the SQL Ops guide as
per below
http://support.microsoft.com/defaul...kb;en-us;829024
also below, which is based around MSF anyway
http://www.microsoft.com/resources/...se/default.mspx
cheers,
Andy.
"TO" <anonymous@.discussions.microsoft.com> wrote in message
news:143001c48c3a$6214ab10$a601280a@.phx.gbl...
> If someone can provide a good guideline for finding
> Database centric documentation, which would include naming
> convention, Design & Pattern, Process & Procedure and such.
> This guide would be something like MSF, but with more
> details in planning, implementation, development,
> deployment, maintenance, and troubleshooting.
> Thanks in advance.

Database Documentation

If someone can provide a good guideline for finding
Database centric documentation, which would include naming
convention, Design & Pattern, Process & Procedure and such.
This guide would be something like MSF, but with more
details in planning, implementation, development,
deployment, maintenance, and troubleshooting.
Thanks in advance.from the Operational side , there is some good stuff in the SQL Ops guide as
per below
http://support.microsoft.com/default.aspx?scid=kb;en-us;829024
also below, which is based around MSF anyway
http://www.microsoft.com/resources/practices/database/default.mspx
cheers,
Andy.
"TO" <anonymous@.discussions.microsoft.com> wrote in message
news:143001c48c3a$6214ab10$a601280a@.phx.gbl...
> If someone can provide a good guideline for finding
> Database centric documentation, which would include naming
> convention, Design & Pattern, Process & Procedure and such.
> This guide would be something like MSF, but with more
> details in planning, implementation, development,
> deployment, maintenance, and troubleshooting.
> Thanks in advance.

Database Documentation

If someone can provide a good guideline for finding
Database centric documentation, which would include naming
convention, Design & Pattern, Process & Procedure and such.
This guide would be something like MSF, but with more
details in planning, implementation, development,
deployment, maintenance, and troubleshooting.
Thanks in advance.
from the Operational side , there is some good stuff in the SQL Ops guide as
per below
http://support.microsoft.com/default...b;en-us;829024
also below, which is based around MSF anyway
http://www.microsoft.com/resources/p...e/default.mspx
cheers,
Andy.
"TO" <anonymous@.discussions.microsoft.com> wrote in message
news:143001c48c3a$6214ab10$a601280a@.phx.gbl...
> If someone can provide a good guideline for finding
> Database centric documentation, which would include naming
> convention, Design & Pattern, Process & Procedure and such.
> This guide would be something like MSF, but with more
> details in planning, implementation, development,
> deployment, maintenance, and troubleshooting.
> Thanks in advance.

Sunday, March 11, 2012

Database diagrams

Hi
I'm trying to view a SQL 2000 Diagram that was created by my colleage. When
I click on "Design Diagram" it appears blank (ie it does show any of the
table links). However if I create a diagram I can view that and my colleage I
can view the diagram that I've created and my colleage can also view it.
Any ideas.
TIA
Dwight
Dwight,
Did you apply Visual Studio Service Pack 6?
If so, this has happened to many people. I don't know if
there is a knowledge base article or supported fix for the
issue. Others have reported working around the issue by
installing an older version of mdt2df.dll
-Sue
On Mon, 10 Jan 2005 03:47:03 -0800, Dwight
<Dwight@.discussions.microsoft.com> wrote:

>Hi
>I'm trying to view a SQL 2000 Diagram that was created by my colleage. When
>I click on "Design Diagram" it appears blank (ie it does show any of the
>table links). However if I create a diagram I can view that and my colleage I
>can view the diagram that I've created and my colleage can also view it.
>Any ideas.
>TIA
>Dwight
|||Hi Sue,
Yes I have install VS SP6. I'll see if I can find an old version of
mdt2df.dll and reinstall it.
Thanks
"Sue Hoegemeier" wrote:

> Dwight,
> Did you apply Visual Studio Service Pack 6?
> If so, this has happened to many people. I don't know if
> there is a knowledge base article or supported fix for the
> issue. Others have reported working around the issue by
> installing an older version of mdt2df.dll
> -Sue
> On Mon, 10 Jan 2005 03:47:03 -0800, Dwight
> <Dwight@.discussions.microsoft.com> wrote:
>
>

Thursday, March 8, 2012

Database diagrams

Hi
I'm trying to view a SQL 2000 Diagram that was created by my colleage. When
I click on "Design Diagram" it appears blank (ie it does show any of the
table links). However if I create a diagram I can view that and my colleage
I
can view the diagram that I've created and my colleage can also view it.
Any ideas.
TIA
DwightDwight,
Did you apply Visual Studio Service Pack 6?
If so, this has happened to many people. I don't know if
there is a knowledge base article or supported fix for the
issue. Others have reported working around the issue by
installing an older version of mdt2df.dll
-Sue
On Mon, 10 Jan 2005 03:47:03 -0800, Dwight
<Dwight@.discussions.microsoft.com> wrote:

>Hi
>I'm trying to view a SQL 2000 Diagram that was created by my colleage. When
>I click on "Design Diagram" it appears blank (ie it does show any of the
>table links). However if I create a diagram I can view that and my colleage
I
>can view the diagram that I've created and my colleage can also view it.
>Any ideas.
>TIA
>Dwight|||Hi Sue,
Yes I have install VS SP6. I'll see if I can find an old version of
mdt2df.dll and reinstall it.
Thanks
"Sue Hoegemeier" wrote:

> Dwight,
> Did you apply Visual Studio Service Pack 6?
> If so, this has happened to many people. I don't know if
> there is a knowledge base article or supported fix for the
> issue. Others have reported working around the issue by
> installing an older version of mdt2df.dll
> -Sue
> On Mon, 10 Jan 2005 03:47:03 -0800, Dwight
> <Dwight@.discussions.microsoft.com> wrote:
>
>

Database diagrams

Hi
I'm trying to view a SQL 2000 Diagram that was created by my colleage. When
I click on "Design Diagram" it appears blank (ie it does show any of the
table links). However if I create a diagram I can view that and my colleage I
can view the diagram that I've created and my colleage can also view it.
Any ideas.
TIA
DwightDwight,
Did you apply Visual Studio Service Pack 6?
If so, this has happened to many people. I don't know if
there is a knowledge base article or supported fix for the
issue. Others have reported working around the issue by
installing an older version of mdt2df.dll
-Sue
On Mon, 10 Jan 2005 03:47:03 -0800, Dwight
<Dwight@.discussions.microsoft.com> wrote:
>Hi
>I'm trying to view a SQL 2000 Diagram that was created by my colleage. When
>I click on "Design Diagram" it appears blank (ie it does show any of the
>table links). However if I create a diagram I can view that and my colleage I
>can view the diagram that I've created and my colleage can also view it.
>Any ideas.
>TIA
>Dwight|||Hi Sue,
Yes I have install VS SP6. I'll see if I can find an old version of
mdt2df.dll and reinstall it.
Thanks
"Sue Hoegemeier" wrote:
> Dwight,
> Did you apply Visual Studio Service Pack 6?
> If so, this has happened to many people. I don't know if
> there is a knowledge base article or supported fix for the
> issue. Others have reported working around the issue by
> installing an older version of mdt2df.dll
> -Sue
> On Mon, 10 Jan 2005 03:47:03 -0800, Dwight
> <Dwight@.discussions.microsoft.com> wrote:
> >Hi
> >
> >I'm trying to view a SQL 2000 Diagram that was created by my colleage. When
> >I click on "Design Diagram" it appears blank (ie it does show any of the
> >table links). However if I create a diagram I can view that and my colleage I
> >can view the diagram that I've created and my colleage can also view it.
> >
> >Any ideas.
> >
> >TIA
> >Dwight
>

Wednesday, March 7, 2012

Database Designing...

Friends,
Who is responsible for the Design of Database? System Analyst, DBA, Databse Designer, Project Leader? Coz I am working as a System Analyst, but now desgining the Databse for the ERP package which I feel is another man's work. Confussed. Plz help me.
AnilI'll wait for the follow-up poll: Who gets blamed for a poorly designed database?

A: DBA
B: DBA
C: DBA
D: All of the above.|||you're kidding, right?

you have four people, and one of them is a Database Designer, and you're asking whose job it is to design the database?

answer: not the DBA

the DBA's job is to create the physical database from the finished database design

answer: not the project leader

the project leader's job is to talk to management

answer: not the systems analyst

the system analyst's job is to figure out what the users really want, not what they're asking for

let's see, have i missed anybody?|||Yeah r937 you missed someone. You missed the poor suckers that have to perform all of those roles. I'm stuck in that position right now. I know the most about the business processes, db design, dba work, java coding, object modeling, reporting progress to management, and managing interaction with the end users. It sux but it acts as great leverage when negotiating salary.|||I don't see any reason or advantage to splitting the DBA and Database Designer roles. It sounds like a recipe for turf wars to me.

Anybody?|||Originally posted by blindman
I'll wait for the follow-up poll: Who gets blamed for a poorly designed database?

A: DBA
B: DBA
C: DBA
D: All of the above.

You took the words right out of my keyboard :)|||you can't see any advantage to splitting the DBA and Database Designer roles?

whoa, you must be trollin

where to start?

how about: if the Database Designer designs the database, sufficient time and effort will be devoted to the understanding and identification of candidate keys based on business logic, whereas if the DBA does it, you get surrogate autonumber primary keys on every table and $deity knows what other similar crap

how's that?

;)|||Do you mean to say a DBA has no knowledge of Database design ...

Buzz ... You are wrong ... what we are talking about is an Integration of DBA and DD roles ... and that would be absolutely great if the person posseses enough DD and DBA knowledge .|||Well, in large shops it doesn't seem to fly. I'D LOVE TO:

- do the analysis
- do the design
- and do what I do on a daily basis (DBA stuff)

Turf wars is what we have here.

But the sad part is, that after the design is handed over to me to implement (mind you I am not invited to any of the meatings held by the project development team), I find all kinds of design issues in about 70% of the projects. At that point it's too late to take it back to the designer, or rather to the systems analyst, because success is declared and propagated all the way to the top, and I still love my job ;) So what am I left with? MAKE IT WORK!!! Recently the "designers" started listening to me a little more (I AM SHOCKED!) and started implementing any data access through a stored procedure. So, having a break like this, I have a luxury to re-write the procedure if it needs to be, and even alter table structures and relations, because the data is not directly accessed. It's a workaround that I found, but it keeps me occupied (not right now, it's boring here, everything works...)|||no, i do not mean to say the DBA has no knowledge of database design

that'd be silly, and i wouldn't say that

and who said we were talking about an integration of roles?

i thought we were talking about a0060162742357's situation where there is already two people, one of them a database designer and the other a DBA, and the question is, whose job is it to design the database?

duh...|||Database Designer
DBA
Project Leader
Programmer

hmmm .. these guys are there and still the system analyst is designing the db ... wierd|||Unfortunately it really doesnt matter who does it because the pooch usually gets screwed right from the beginning and then you have to spend the rest of your days working around a flawed design.

those magnificent bastards|||Originally posted by Ruprect
those magnificent bastards Do they come any other way ?!?!

-PatP|||How about all the "little" projects where the project manager says something like: "We only have two tables to hold our data, why don't we just dump them in the products database?"

Hmm. Would the fact that it is not product data have anything to do with that decision (or lack thereof)?

Sadly, we have no database design group here. All the developers are free to come up with their own designs, which I find out about later. And let me tell you, we have a creative bunch around here...

How are all of your shops made up? We only have project managers, programmers, and DBA.|||All very interesting comments.

So, in a split DBA/Designer environment, should the DBA be responsble only for pure "admin" functions, such as backups, index optimization, replication, etc?

I think it is absolutely essential that a database designer have good knowledge of database administration, though I don't think the reverse is necessarilly required.

I've only worked in small-to-midsize shops where I was the one-man show, so I'm curious about how duties are split in larger environments and how people keep from stepping on eachother's toes.|||The word is "micromanagement"...Or is it 2 words?|||or the client who says i want to bring these 900 various access 97 2000 and excel files into a sql server database

bottom line the only one who cares that the model is done right, is you.

it's like paul newman said
"only cream and bastards rise"|||Originally posted by blindman
All very interesting comments.

So, in a split DBA/Designer environment, should the DBA be responsble only for pure "admin" functions, such as backups, index optimization, replication, etc?

I think it is absolutely essential that a database designer have good knowledge of database administration, though I don't think the reverse is necessarilly required.

I've only worked in small-to-midsize shops where I was the one-man show, so I'm curious about how duties are split in larger environments and how people keep from stepping on eachother's toes.

I kind of disagree about the database administration piece. It would be impossible for me to be a good DBA if I didn't know about database design. I can only do so much with backups, recoveries, replication, etc.

How would I optimize the indexes and do performance tuning well though if I didn't understand database design. Half of performance tuning is knowing how proper design works and seeing where you can improve performance by applying indexes properly in the design, restructuring entities to be more efficient, and identifying weak code through analysis of the underlying structure.|||I don't disagree with you. I just feel that tweaking indexes falls within the realm of the DBA (though a designer has to plan for indexes as well). Indexes can be changed without modifying the structure or functionality of the schema, so I don't think of them as being the exclusive realm of the designer.|||Friends,
Thanx for ur suggestions n explanations. So Can I conclude that:

A system analyst : feeds the DD with user reqs and other high level flow diagrams.

A DD : models and designs the DB

A DBA (with the help of DD) : creates the Physical Database and Admins it, gives it PL

A PL : uses the info from SA and DBA+DD to develope the System(software)

A programmer : An OX

Am I Right?

Regards,

Anil,
the inexperienced|||This is a typical distribution of tasks, but I would argue that it has several flaws.

I think the Database Designer should create the physical database, though in a development environment. When it is done (or during development) the DBA should review it, and the DBA should be responsible for rolling it out to the production environment.

Also, the Database Designer should be involved with the application design from the start, including requirements gathering and functionality. I think a lot of problems occur when a system analyst and other parties gather requirements and design interfaces and then just hand the package off the the designer with the instructions to "build this". An allegory would be many of Frank Lloyd Wright's architectural designs, which may have been innovative and attractive, but were structurally unsound. The Database Designer should be a critical part of the development team.|||any competent database designer who finds himself or herself not included in the overall systems design and user requirements analysis will not stay in that job for long

Database Designing tools

Hi all,
Does anyone know how I can design the database schema. I mean what tools can be used to the design the database and view the table relationships, etc. TIA.

Vik!Enterprise Manager? Makes a pretty good job in SQL Server for this.

database design??

Hello,

I am designing my first database with 5 tables for a demo project and am not sure if it works. an example below.

2 of the many things I want visitors to the site to do is find a company by the industry sector they belong to,..and

what sort of service or products they can supply. For instance a Employment agency maybe under professional services

Table 1 Customer

Customer_ID = primary key,,,, Sector_ID = Foreign key

Comapany Name, Address, Phone, Postcode etc

Tabel 2 Industry Sectors

Sector_ID = primary key,,,,Customer_ID= foreign key

banking, Education,Prof Services, etc

Table 3 Trading Activity

Trading_ID = primary key,,,,Sector_ID = Foreign key, Products_ID= Fk

Employment Agent, School, Lawyer etc

Table 4 Products

Products_ID = primary key,,,,Trading_ID = foreign key

Supply frozen foods, transport services, sports goods, etc

Table 5 Account

Account_ID = primary key,,,,Customer_ID = foreign key

Account Name, Credit Limit, Payment Terms, Open date, Account contact etc

One big point of confusion is, can I have the Customer_ID from the principal Customers table

in every table as a foreign key or must the tables be chained together one after the other as such.

Advice appreciated

Thanks

Hi

There are some problems in your design.First thers are some general rules you should keep in mind.

For 2 objects A B, if there are 1-many relation between A and B, primary key of A should be inculded as foreign key in B .

if there are many-1 relation between A and B, primary key of B should be inculded as foreign key in A .

if there are many-many relation between A and B, you need to create a new table A-B,primary key of B and A should be inculded in the new table

if there are 1-1 relation between A and B, Columns of A and B could be included in a single table .

For table1 and table2 if one customer belongs to many industry sectors and one industry sectors have many customers ,then you should create a new table with primary key of talbe1 and table2 inculded. Table 3 and talbe 4 are the same.

If I misunderstand your meaning ,pls tell me .

Database Design. Need Advice. Thank You.

Hello,
I am creating a database where:
- I have a Blogs and Folders system.
- Use a common design so I can implement new systems in the future.
Users, Comments, Ratings, View, Tags and Categories are tables common
to all systems, i.e., used by Posts and Files in Blogs and Folders.
- One Tag or Category can be associated to many Posts or Files.
- One Comment, View or Rating should be only associated to one Post or
one File. I am missing this ... (1)
Relations between a File / Folder and Comments / Ratings / View /
Tags / Categories are done using FilesRatings, FoldersViews, etc.
I am using UniqueIdentifier as Primary Keys.
I checked ASP.NET Membership tables, a few articles and few features
in my project, such as renaming files with the GUID of their records.
I didn't decided yet for INT or UNIQUEIDENTIFIER.
I am looking for some feedback on the design of my database.
One thing I think need to improve is mentioned in (1)
But any advices to improve it would be great.
Thank You,
Miguel
My Database Script:
-- Users ...
create table dbo.Users
(
UserID uniqueidentifier not null
constraint PK_User primary key clustered,
[Name] nvarchar(200) not null,
Email nvarchar(200) null,
UpdatedDate datetime not null
)
-- Categories ...
create table dbo.Categories
(
CategoryID uniqueidentifier not null
constraint PK_Category primary key clustered,
[Name] nvarchar(100) not null
)
-- Comments ...
create table dbo.Comments
(
CommentID uniqueidentifier not null
constraint PK_Comment primary key clustered,
AuthorID uniqueidentifier not null,
Title nvarchar(400) null,
Body nvarchar(max) null,
UpdatedDate datetime not null,
constraint FK_Comments_Users
foreign key(AuthorID)
references dbo.Users(UserID)
)
-- Ratings ...
create table dbo.Ratings
(
RatingID uniqueidentifier not null
constraint PK_Rating primary key clustered,
AuthorID uniqueidentifier not null,
Value float not null,
constraint FK_Ratings_Users
foreign key(AuthorID)
references dbo.Users(UserID)
)
-- Tags ...
create table dbo.Tags
(
TagID uniqueidentifier not null
constraint PK_Tag primary key clustered,
[Name] nvarchar(100) not null
)
-- Views ...
create table dbo.Views
(
ViewID uniqueidentifier not null
constraint PK_View primary key clustered,
Ticket [datetime] not null
)
-- Blogs ...
create table dbo.Blogs
(
BlogID uniqueidentifier not null
constraint PK_Blog primary key clustered,
Title nvarchar(400) null,
Description nvarchar(2000) null,
CreatedDate datetime null
)
-- Posts ...
create table dbo.Posts
(
PostID uniqueidentifier not null
constraint PK_Post primary key clustered,
BlogID uniqueidentifier not null,
AuthorID uniqueidentifier not null,
Title nchar(1000) null,
Body nvarchar(max) null,
UpdatedDate datetime not null,
IsPublished bit not null,
constraint FK_Posts_Blogs
foreign key(BlogID)
references dbo.Blogs(BlogID)
on delete cascade,
constraint FK_Posts_Users
foreign key(AuthorID)
references dbo.Users(UserID)
on delete cascade
)
-- PostsCategories ...
create table dbo.PostsCategories
(
PostID uniqueidentifier not null,
CategoryID uniqueidentifier not null,
constraint PK_PostsCategories
primary key clustered (PostID, CategoryID),
constraint FK_PostsCategories_Posts
foreign key(PostID)
references dbo.Posts(PostID)
on delete cascade,
constraint FK_PostsCategories_Categories
foreign key(CategoryID)
references dbo.Categories(CategoryID)
)
-- PostsComments ...
create table dbo.PostsComments
(
PostID uniqueidentifier not null,
CommentID uniqueidentifier not null,
constraint PK_PostsComments
primary key clustered (PostID, CommentID),
constraint FK_PostsComments_Posts
foreign key(PostID)
references dbo.Posts(PostID)
on delete cascade,
constraint FK_PostsComments_Comments
foreign key(CommentID)
references dbo.Comments(CommentID)
on delete cascade
)
-- PostsRatings ...
create table dbo.PostsRatings
(
PostID uniqueidentifier not null,
RatingID uniqueidentifier not null,
constraint PK_PostsRatings
primary key clustered (PostID, RatingID),
constraint FK_PostsRatings_Posts
foreign key(PostID)
references dbo.Posts(PostID)
on delete cascade,
constraint FK_PostsRatings_Ratings
foreign key(RatingID)
references dbo.Ratings(RatingID)
on delete cascade
)
-- PostsTags ...
create table dbo.PostsTags
(
PostID uniqueidentifier not null,
TagID uniqueidentifier not null,
constraint PK_PostsTags
primary key clustered (PostID, TagID),
constraint FK_PostsTags_Posts
foreign key(PostID)
references dbo.Posts(PostID)
on delete cascade,
constraint FK_PostsTags_Tags
foreign key(TagID)
references dbo.Tags(TagID)
)
-- PostsViews ...
create table dbo.PostsViews
(
PostID uniqueidentifier not null,
ViewID uniqueidentifier not null,
constraint PK_PostsViews
primary key clustered (PostID, ViewID),
constraint FK_PostsViews_Posts
foreign key(PostID)
references dbo.Posts(PostID)
on delete cascade,
constraint FK_PostsViews_Views
foreign key(ViewID)
references dbo.Views(ViewID)
on delete cascade
)
-- Folders ...
create table dbo.Folders
(
FolderID uniqueidentifier not null
constraint PK_Folder primary key clustered,
[Name] nvarchar(100) null,
Description nvarchar(2000) null,
CreatedDate datetime not null,
URL nvarchar(400) not null
)
-- Files ...
create table dbo.Files
(
FileID uniqueidentifier not null
constraint PK_File primary key clustered,
FolderID uniqueidentifier not null,
AuthorID uniqueidentifier not null,
Title nvarchar(400) null,
Description nvarchar(2000) null,
[Name] nvarchar(100) not null,
URL nvarchar(400) not null,
UpdatedDate datetime not null,
IsPublished bit not null,
Type nvarchar(50) null,
constraint FK_Files_Folders
foreign key(FolderID)
references dbo.Folders(FolderID)
on delete cascade,
constraint FK_Files_Users
foreign key(AuthorID)
references dbo.Users(UserID)
on delete cascade
)
-- FilesCategories ...
create table dbo.FilesCategories
(
FileID uniqueidentifier not null,
CategoryID uniqueidentifier not null,
constraint PK_FilesCategories
primary key clustered (FileID, CategoryID),
constraint FK_FilesCategories_Files
foreign key(FileID)
references dbo.Files(FileID)
on delete cascade,
constraint FK_FilesCategories_Categories
foreign key(CategoryID)
references dbo.Categories(CategoryID)
)
-- FilesComments ...
create table dbo.FilesComments
(
FileID uniqueidentifier not null,
CommentID uniqueidentifier not null,
constraint PK_FilesComments
primary key clustered (FileID, CommentID),
constraint FK_FilesComments_Files
foreign key(FileID)
references dbo.Files(FileID)
on delete cascade,
constraint FK_FilesComments_Comments
foreign key(CommentID)
references dbo.Comments(CommentID)
on delete cascade
)
-- FilesRatings ...
create table dbo.FilesRatings
(
FileID uniqueidentifier not null,
RatingID uniqueidentifier not null,
constraint PK_FilesRatings
primary key clustered (FileID, RatingID),
constraint FK_FilesRatings_Files
foreign key(FileID)
references dbo.Files(FileID)
on delete cascade,
constraint FK_FilesRatings_Ratings
foreign key(RatingID)
references dbo.Ratings(RatingID)
on delete cascade
)
-- FilesTags ...
create table dbo.FilesTags
(
FileID uniqueidentifier not null,
TagID uniqueidentifier not null,
constraint PK_FilesTags
primary key clustered (FileID, TagID),
constraint FK_FilesTags_Files
foreign key(FileID)
references dbo.Files(FileID)
on delete cascade,
constraint FK_FilesTags_Tags
foreign key(TagID)
references dbo.Tags(TagID)
)
-- FilesViews ...
create table dbo.FilesViews
(
FileID uniqueidentifier not null,
ViewID uniqueidentifier not null,
constraint PK_FilesViews
primary key clustered (FileID, ViewID),
constraint FK_FilesViews_Files
foreign key(FileID)
references dbo.Files(FileID)
on delete cascade,
constraint FK_FilesViews_Views
foreign key(ViewID)
references dbo.Views(ViewID)
on delete cascade
)
-- Run script
goOn Oct 22, 12:21 am, shapper <mdmo...@.gmail.com> wrote:
> Hello,
> I am creating a database where:
> - I have a Blogs and Folders system.
> - Use a common design so I can implement new systems in the future.
> Users, Comments, Ratings, View, Tags and Categories are tables common
> to all systems, i.e., used by Posts and Files in Blogs and Folders.
> - One Tag or Category can be associated to many Posts or Files.
> - One Comment, View or Rating should be only associated to one Post or
> one File. I am missing this ... (1)
> Relations between a File / Folder and Comments / Ratings / View /
> Tags / Categories are done using FilesRatings, FoldersViews, etc.
> I am using UniqueIdentifier as Primary Keys.
> I checked ASP.NET Membership tables, a few articles and few features
> in my project, such as renaming files with the GUID of their records.
> I didn't decided yet for INT or UNIQUEIDENTIFIER.
> I am looking for some feedback on the design of my database.
> One thing I think need to improve is mentioned in (1)
> But any advices to improve it would be great.
> Thank You,
> Miguel
> My Database Script:
> -- Users ...
> create table dbo.Users
> (
> UserID uniqueidentifier not null
> constraint PK_User primary key clustered,
> [Name] nvarchar(200) not null,
> Email nvarchar(200) null,
> UpdatedDate datetime not null
> )
> -- Categories ...
> create table dbo.Categories
> (
> CategoryID uniqueidentifier not null
> constraint PK_Category primary key clustered,
> [Name] nvarchar(100) not null
> )
> -- Comments ...
> create table dbo.Comments
> (
> CommentID uniqueidentifier not null
> constraint PK_Comment primary key clustered,
> AuthorID uniqueidentifier not null,
> Title nvarchar(400) null,
> Body nvarchar(max) null,
> UpdatedDate datetime not null,
> constraint FK_Comments_Users
> foreign key(AuthorID)
> references dbo.Users(UserID)
> )
> -- Ratings ...
> create table dbo.Ratings
> (
> RatingID uniqueidentifier not null
> constraint PK_Rating primary key clustered,
> AuthorID uniqueidentifier not null,
> Value float not null,
> constraint FK_Ratings_Users
> foreign key(AuthorID)
> references dbo.Users(UserID)
> )
> -- Tags ...
> create table dbo.Tags
> (
> TagID uniqueidentifier not null
> constraint PK_Tag primary key clustered,
> [Name] nvarchar(100) not null
> )
> -- Views ...
> create table dbo.Views
> (
> ViewID uniqueidentifier not null
> constraint PK_View primary key clustered,
> Ticket [datetime] not null
> )
> -- Blogs ...
> create table dbo.Blogs
> (
> BlogID uniqueidentifier not null
> constraint PK_Blog primary key clustered,
> Title nvarchar(400) null,
> Description nvarchar(2000) null,
> CreatedDate datetime null
> )
> -- Posts ...
> create table dbo.Posts
> (
> PostID uniqueidentifier not null
> constraint PK_Post primary key clustered,
> BlogID uniqueidentifier not null,
> AuthorID uniqueidentifier not null,
> Title nchar(1000) null,
> Body nvarchar(max) null,
> UpdatedDate datetime not null,
> IsPublished bit not null,
> constraint FK_Posts_Blogs
> foreign key(BlogID)
> references dbo.Blogs(BlogID)
> on delete cascade,
> constraint FK_Posts_Users
> foreign key(AuthorID)
> references dbo.Users(UserID)
> on delete cascade
> )
> -- PostsCategories ...
> create table dbo.PostsCategories
> (
> PostID uniqueidentifier not null,
> CategoryID uniqueidentifier not null,
> constraint PK_PostsCategories
> primary key clustered (PostID, CategoryID),
> constraint FK_PostsCategories_Posts
> foreign key(PostID)
> references dbo.Posts(PostID)
> on delete cascade,
> constraint FK_PostsCategories_Categories
> foreign key(CategoryID)
> references dbo.Categories(CategoryID)
> )
> -- PostsComments ...
> create table dbo.PostsComments
> (
> PostID uniqueidentifier not null,
> CommentID uniqueidentifier not null,
> constraint PK_PostsComments
> primary key clustered (PostID, CommentID),
> constraint FK_PostsComments_Posts
> foreign key(PostID)
> references dbo.Posts(PostID)
> on delete cascade,
> constraint FK_PostsComments_Comments
> foreign key(CommentID)
> references dbo.Comments(CommentID)
> on delete cascade
> )
> -- PostsRatings ...
> create table dbo.PostsRatings
> (
> PostID uniqueidentifier not null,
> RatingID uniqueidentifier not null,
> constraint PK_PostsRatings
> primary key clustered (PostID, RatingID),
> constraint FK_PostsRatings_Posts
> foreign key(PostID)
> references dbo.Posts(PostID)
> on delete cascade,
> constraint FK_PostsRatings_Ratings
> foreign key(RatingID)
> references dbo.Ratings(RatingID)
> on delete cascade
> )
> -- PostsTags ...
> create table dbo.PostsTags
> (
> PostID uniqueidentifier not null,
> TagID uniqueidentifier not null,
> constraint PK_PostsTags
> primary key clustered (PostID, TagID),
> constraint FK_PostsTags_Posts
> foreign key(PostID)
> references dbo.Posts(PostID)
> on delete cascade,
> constraint FK_PostsTags_Tags
> foreign key(TagID)
> references dbo.Tags(TagID)
> )
> -- PostsViews ...
> create table dbo.PostsViews
> (
> PostID uniqueidentifier not null,
> ViewID uniqueidentifier not null,
> constraint PK_PostsViews
> primary key clustered (PostID, ViewID),
> constraint FK_PostsViews_Posts
> foreign key(PostID)
> references dbo.Posts(PostID)
> on delete cascade,
> constraint FK_PostsViews_Views
> foreign key(ViewID)
> references dbo.Views(ViewID)
> on delete cascade
> )
> -- Folders ...
> create table dbo.Folders
> (
> FolderID uniqueidentifier not null
> constraint PK_Folder primary key clustered,
> [Name] nvarchar(100) null,
> Description nvarchar(2000) null,
> CreatedDate datetime not null,
> URL nvarchar(400) not null
> )
> -- Files ...
> create table dbo.Files
> (
> FileID uniqueidentifier not null
> constraint PK_File primary key clustered,
> FolderID uniqueidentifier not null,
> AuthorID uniqueidentifier not null,
> Title nvarchar(400) null,
> Description nvarchar(2000) null,
> [Name] nvarchar(100) not null,
> URL nvarchar(400) not null,
> UpdatedDate datetime not null,
> IsPublished bit not null,
> Type nvarchar(50) null,
> constraint FK_Files_Folders
> foreign key(FolderID)
> references dbo.Folders(FolderID)
> on delete cascade,
> constraint FK_Files_Users
> foreign key(AuthorID)
> references dbo.Users(UserID)
> on delete cascade
> )
> -- FilesCategories ...
> create table dbo.FilesCategories
> (
> FileID uniqueidentifier not null,
> CategoryID uniqueidentifier not null,
> constraint PK_FilesCategories
> primary key clustered (FileID, CategoryID),
> constraint FK_FilesCategories_Files
> foreign key(FileID)
> references dbo.Files(FileID)
> on delete cascade,
> constraint FK_FilesCategories_Categories
> foreign key(CategoryID)
> references dbo.Categories(CategoryID)
> )
> -- FilesComments ...
> create table dbo.FilesComments
> (
> FileID uniqueidentifier not null,
> CommentID uniqueidentifier not null,
> constraint PK_FilesComments
> primary key clustered (FileID, CommentID),
> constraint FK_FilesComments_Files
> foreign key(FileID)
> references dbo.Files(FileID)
> on delete cascade,
> constraint FK_FilesComments_Comments
> foreign key(CommentID)
> references dbo.Comments(CommentID)
> on delete cascade
> )
> -- FilesRatings ...
> create table dbo.FilesRatings
> (
> FileID uniqueidentifier not null,
> RatingID uniqueidentifier not null,
> constraint PK_FilesRatings
> primary key clustered (FileID, RatingID),
> constraint FK_FilesRatings_Files
> foreign key(FileID)
> references dbo.Files(FileID)
> on delete cascade,
> constraint FK_FilesRatings_Ratings
> foreign key(RatingID)
> references dbo.Ratings(RatingID)
> on delete cascade
> )
> -- FilesTags ...
> create table dbo.FilesTags
> (
> FileID uniqueidentifier not null,
> TagID uniqueidentifier not null,
> constraint PK_FilesTags
> primary key clustered (FileID, TagID),
> constraint FK_FilesTags_Files
> foreign key(FileID)
> references dbo.Files(FileID)
> on delete cascade,
> constraint FK_FilesTags_Tags
> foreign key(TagID)
> references dbo.Tags(TagID)
> )
> -- FilesViews ...
> create table dbo.FilesViews
> (
> FileID uniqueidentifier not null,
> ViewID uniqueidentifier not null,
> constraint PK_FilesViews
> primary key clustered (FileID, ViewID),
> constraint FK_FilesViews_Files
> foreign key(FileID)
> references dbo.Files(FileID)
> on delete cascade,
> constraint FK_FilesViews_Views
> foreign key(ViewID)
> references dbo.Views(ViewID)
> on delete cascade
> )
> -- Run script
> go
Please, anyone?
Does someone sees a way to improve this?
Thanks,
Miguel

Database design, inherit

I have a database that looks something like this:

Table: Creature
Fields, CreatureId {PK}, ...

Table: Bug
Fields: BugId {PK}, CreatureId {FK}...

Table: LadyBird
Fields: LadyBirdId {PK}, BugId {FK}...

Every creature in the system is in the Creature-table. If the creature
also is a bug, then it's also in the bug table. And if it's a
LadyBird, it's also in the LadyBird-table.

A problem with the current design is that several bugs could be of the
same creature, and several LadyBirds could be of the same bug which
should not be possible.

So I'm thinking about removing the fields BugId and LadyBirdId, and
use CreatureId (as primary key) instead in the bug and ladybird table.
Would that improve the design of the database? With a new design it's
possible to have a LadyBird that's not a Bug.

I still thinks the new design would be better, but I'm gladly accept
advices before I starts the redesign (which will be quite some work to
do :-/ )

PEKThe classic scenario calls for a root class with all the common
attributes and then specialized sub-classes under it. As an example,
let's take the class of Vehicles and find an industry standard
identifier (VIN), and add two mutually exclusive sub-classes, Sport
utility vehicles and sedans ('SUV', 'SED').

CREATE TABLE Vehicles
(vin CHAR(17) NOT NULL PRIMARY KEY,
vehicle_type CHAR(3) NOT NULL
CHECK(vehicle_type IN ('SUV', 'SED')),
UNIQUE (vin, vehicle_type),
..);

Notice the overlapping candidate keys. I then use a compound candidate
key (vin, vehicle_type) and a constraint in each sub-class table to
assure that the vehicle_type is locked and agrees with the Vehicles
table. Add some DRI actions and you are done:

CREATE TABLE SUV
(vin CHAR(17) NOT NULL PRIMARY KEY,
vehicle_type CHAR(3) DEFAULT 'SUV' NOT NULL
CHECK(vehicle_type = 'SUV'),
UNIQUE (vin, vehicle_type),
FOREIGN KEY (vin, vehicle_type)
REFERENCES Vehicles(vin, vehicle_type)
ON UPDATE CASCADE
ON DELETE CASCADE,
..);

CREATE TABLE Sedans
(vin CHAR(17) NOT NULL PRIMARY KEY,
vehicle_type CHAR(3) DEFAULT 'SED' NOT NULL
CHECK(vehicle_type = 'SED'),
UNIQUE (vin, vehicle_type),
FOREIGN KEY (vin, vehicle_type)
REFERENCES Vehicles(vin, vehicle_type)
ON UPDATE CASCADE
ON DELETE CASCADE,
..);

I can continue to build a hierarchy like this. For example, if I had a
Sedans table that broke down into two-door and four-door sedans, I
could a schema like this:

CREATE TABLE Sedans
(vin CHAR(17) NOT NULL PRIMARY KEY,
vehicle_type CHAR(3) DEFAULT 'SED' NOT NULL
CHECK(vehicle_type IN ('2DR', '4DR', 'SED')),
UNIQUE (vin, vehicle_type),
FOREIGN KEY (vin, vehicle_type)
REFERENCES Vehicles(vin, vehicle_type)
ON UPDATE CASCADE
ON DELETE CASCADE,
..);

CREATE TABLE TwoDoor
(vin CHAR(17) NOT NULL PRIMARY KEY,
vehicle_type CHAR(3) DEFAULT '2DR' NOT NULL
CHECK(vehicle_type = '2DR'),
UNIQUE (vin, vehicle_type),
FOREIGN KEY (vin, vehicle_type)
REFERENCES Sedans(vin, vehicle_type)
ON UPDATE CASCADE
ON DELETE CASCADE,
..);

CREATE TABLE FourDoor
(vin CHAR(17) NOT NULL PRIMARY KEY,
vehicle_type CHAR(3) DEFAULT '4DR' NOT NULL
CHECK(vehicle_type = '4DR'),
UNIQUE (vin, vehicle_type),
FOREIGN KEY (vin, vehicle_type)
REFERENCES Sedans (vin, vehicle_type)
ON UPDATE CASCADE
ON DELETE CASCADE,
..);

The idea is to build a chain of identifiers and types in a UNIQUE()
constraint that go up the tree when you use a REFERENCES constraint.
Obviously, you can do variants of this trick to get different class
structures.

If an entity doesn't have to be exclusively one subtype, you play with
the root of the class hierarchy:

CREATE TABLE Vehicles
(vin CHAR(17) NOT NULL,
vehicle_type CHAR(3) NOT NULL
CHECK(vehicle_type IN ('SUV', 'SED')),
PRIMARY KEY (vin, vehicle_type),
..);

Now start hiding all this stuff in VIEWs immediately and add an INSTEAD
OF trigger to those VIEWs. Faking an OO class model like this will be
slow and a bitch to maintain, but there it is. You might want to try a
relational design instead.|||--CELKO-- wrote:
> Now start hiding all this stuff in VIEWs immediately and add an
INSTEAD
> OF trigger to those VIEWs. Faking an OO class model like this will
be
> slow and a bitch to maintain, but there it is. You might want to try
a
> relational design instead.

Thanks for your detailed answer. Adding a "type" key was an clever idea
:-). However, it seems that in some tables (like FourDoor) the type
column will have the same value in every row which I'm not very
comfortable with. But if there is no away around it maybe that's the
way to go.

A relation design may be better, but that's what I'm trying to create
(but sense I think that everything is objects I'm guess that affects my
solution :-). The problem I'm actually trying to solve is something
like this:

I have three tables with animals (say, Bug, Cat and Dog) and three
tables with places (like House, Car and Boat). Every animal could have
(but not always have) an relation every place (like "The cat 12 entered
the house 21 at 21:12"). It's the relation that is the problem. I could
create nine table for every possible solution (but that feels like a
bad design, or?). One generic table would be a more elegant solution. I
see two approaches:

First, inspired from your solution, the tables would look something
like this:
Bug (pk: BugId, AnimalType)
Cat (pk: CatId, AnimalType)
Dog (pk: DogId, AnimalType)
House (pk: HouseId, PlaceType)
Car (pk: CarId, PlaceType)
Boat (pk: BoatId, PlaceType)
AnimalPlace( pk: AnimalId, AnimalType, PlaceId, PlaceType )

The second solution, which I think is better, would require unique id's
as primary keys for the animals and places (so if a cat has id 1,
neither a bug or dog could have id 1). This would remove the type
problem (this is how I thought in the beginning):
Bug (pk: BugId)
Cat (pk: CatId)
Dog (pk: DogId)
House (pk: HouseId)
Car (pk: CarId)
Boat (pk: BoatId)
AnimalPlace( pk: AnimalId, PlaceId, )

Both these solutions has the problem is that I have no idea how to
create the foreign keys in the AnimalPlace table. The AnimalId should
be a foreign key to one the primary keys in the animal tables (BugId,
CatId or DogId). But that is not possible, or? I found this thread with
Google which discussing the problem:

http://groups.google.se/groups?hl=s...link.net#link10

A clever man almost solves the problem in the end. But it requires that
all children is created before there parents (in my case, AnimalPlace
should be created before Cat for example).

So how to handle this problem. Is subclass-superclass the way to solve
this?

PEK

Database Design where some products are T-shirts with different sizes

Hello,

I'm wondering what would be the best approach to designing a database that will have different products one of them being T-Shirts of different sizes... for example 1 t-shirt design might only have 2 available sizes while another may have 4. I'm kinda stumped on how to approach this cuz there is multiple products like CD's, DVD's, Magazines etc which is pretty straight forward, but the T-shirts have this "variable" to it.

What i'm really wondering is should i have 1 main "Products" Table or should i have a separate table for the t-shirts?
Should there be a column for each available size?

Currently my database has a "products table" that has foreign keys to "Product Type", "Artists", "Genre"

The database is basically for a record company

If anyone has designed a database similar to this i'd love any insight or even possibly to see a database diagram

Thanks

Here is my suggestion:

Table: Products
Id - PK
Name
Description
Price

Table: Attributes
Id - PK
Name
Label

Table: AttributeValues
Id - PK
AttributeId - FK
Value

Table: ProductAttributes
Id - PK
ProductId - FK
AttributeId - FK

In your order line, you will have to store the ProductID And then in a child table store the zero to many associated ProductAttributeId's. Here is an example

Table: Products
Id - 1
Name - Men's ABC Polo
Description - Nice Shirt
Price - 20.00
Id - 2
Name - Women's ABC Polo
Description - Nice Shirt
Price - 25.00

Table: Attributes
Id - 100
Name - Men's Sizes
Label - Size
Id - 101
Name - Women's Sizes
Label - Size

Table: AttributeValues
Id - 201
AttributeId - 101
Value - Small
Id - 202
AttributeId - 101
Value - Medium
Id - 203
AttributeId - 101
Value - Large
Id - 204
AttributeId - 101
Value - Extar Large
Id - 205
AttributeId - 102
Value - Extra Small
Id - 206
AttributeId - 102
Value - Small
Id - 207
AttributeId - 102
Value - Medium

Table: ProductAttributes
Id - 300
ProductId - 1
AttributeId - 101
Id - 301
ProductId - 2
AttributeId - 102

The attrubutes are reuseable accross multiple products and the use of attributes is optional. When you take the order you would store the product id of 1 for a Man's polo with the attribute value in another table relating to the line item. You put this in another table so you can have potentially multiple attribute values.

Make sense? Just one way of many... this was off the top of my head and it is late.

Database Design vs Database Modelling..

.. Is it the same thing ? If not whats the difference ?Hi,
Practically for me both are same. But looks like there is few difference.
Take a look into the below URL.
http://www.aisintl.com/case/library/R-Theory_vs_ER/r-theory_vs_er.html
Thanks
Hari
"Hassan" <Hassan@.hotmail.com> wrote in message
news:%23WdsmCq6GHA.4572@.TK2MSFTNGP02.phx.gbl...
> .. Is it the same thing ? If not whats the difference ?
>

Database Design vs Database Modelling..

... Is it the same thing ? If not whats the difference ?
Hi,
Practically for me both are same. But looks like there is few difference.
Take a look into the below URL.
http://www.aisintl.com/case/library/...ory_vs_er.html
Thanks
Hari
"Hassan" <Hassan@.hotmail.com> wrote in message
news:%23WdsmCq6GHA.4572@.TK2MSFTNGP02.phx.gbl...
> .. Is it the same thing ? If not whats the difference ?
>

Database Design vs Database Modelling..

.. Is it the same thing ? If not whats the difference ?Hi,
Practically for me both are same. But looks like there is few difference.
Take a look into the below URL.
http://www.aisintl.com/case/library...eory_vs_er.html
Thanks
Hari
"Hassan" <Hassan@.hotmail.com> wrote in message
news:%23WdsmCq6GHA.4572@.TK2MSFTNGP02.phx.gbl...
> .. Is it the same thing ? If not whats the difference ?
>

Database Design Tool

I've been desiging a database.

From a previous job, I've seen a report that runs off the database management tool in SQL Server 2005 that prints out comments entered at the table and column level. I can't find that report on my current system.

I wondered if this is a feature of the tool when the tool is installed as a client rather than the tool locally on the server, as part of the server install.

Any help is appreciated.

Andrew

Hi Andrew,
Just a guess but maybe you are talking about extended properties?
From the context menu of a table or column you will find a "page" called Extended Properties for that table or column. Should work the same regardless of whether you are on a local SSMS or a remote SSMS. I believe you can also script only the extended properties of all or selected objects if that is interesting. Note that extended properties are optional and must be provided by developer. Otherwise they are blank.
Regards,
Bill
|||

I've found a comment property for both columns and tables. I don't recall going to an 'extended' property page. The comment property at the table level appears on the regular list of table properties at the right of the design tool. To put a comment on a column, I've used the column modify method. I right click on the column and pick 'modify'.

Is the script you refer to something I have to write, or is there an existing script in the tool.

I wasn't paying close enough attention, but I think the output from the report I saw was a Word Doc.

Andrew

|||

There is not anything built in that will generate a word doc but I am sure the community has one, try seaerching some of the following sites;

www.codeplex.com

www.sqlteam.com

www.sqlservercentral.com

www.codeproject.com

Database Design Theory

I have been tasked with creating a Data Warehouse.

Problem is that old storage vs reporting debate.

I have determined that the data that I will recieve and store will be like follows (simplified form) for expandability

KEY FldKEy FldData DateTime AuditTrail

Daily I will use this data based on use input process this data into the following format and say
if fldkey/ flddata open a cycle.
populate row with null close date
if fldkey/ flddata closes cycle
update row with date

If fldkey/ flddata changes a cutable value
update row

if fldkey/ flddata changes a cutable value (type 2 table)
insert a row into detail update value and obsolete previous row.

KEY DateStart DateEnd FLDDATA1 FLDDATE2 Op_Cl_IND HEADER Record

KEY EFFdate OBSDATE FLDdata3 FLDData4 Detail Records
KEY EFFdate OBSDATE FLDdata3 FLDData4
KEY EFFdate OBSDATE FLDdata3 FLDData4

Problem: FLDKey is a finite count however the max is undefined.

IS there any way to solve the problem of not being able to nail down users to tell you what they want to cut by. What I have been instructed by mgr (old IDMS) is that they wish to see all on the FldData and have the ability to cut by all of it. However the Flddata could be anything (cannot be indexed).

400,000,000 rows at least.

Do I need to nail the users down or am I am missing something.

Sorry if so cryptic

:(Too cryptic, and too much jargon. (Cut?, Cycle?)

But this sure doesn't look like a data warehouse project to me.|||Thought so.

User requirement store a undetermined amount of data about an item

Cannot create a structure with
Key Make Model Year Cost Sold Junked
1 Ford Taurus 97 10000 1/1/98 2/28/06
2 Ford Ranger 97 20000 1/12/99 null

Need to create
Key Fieldname data
1 Make Ford
1 Model Taurus
1 Year 97
1 Cost 10000
1 Sold 1/1/98
1 Junked 2/28/06

As the Number of fields captured is not fixed.

Now I need to sum the that in the data field by a cut of that data.
Total Cost of All 1997 Ford Cars and grouped by the age in months of the auto.

Work of a small table to do this however 400 m rows of data over 18 months Tring to find the data 1997 and Ford in the data field then determining the total dollars of those

Well.

Question is there some thing that I am missing or do I need to get the user to define a more static structure. And transform this into a star schema.

The table structure to store the data (Audit trail)

perhaps datamart is a more appropriate term.|||So you're trying to do the logical vertical table thingee...

Why?

There are sooo many bad reasons for doing this...

The concept is that you want to be able to add new "columns" on the fly

I'll tell you this, if you do go this route, you better make sure to use a partitioned view where the tables are in their own file groups and distributed across many physical disks...

I wonder what you would partition on though|||That is my thought that this a bad idea.

I need to convince my MGR and Users to give me more Defined specs.

Was just asking if there is something that I am missing.

The Goal to the Audit Trail is to capture every poteitial detail of a thing. And to get that info If you have that things ID you can do this. However any and look at every detail about this. the other reason for the data structure of the audit trail is scalability of data storage.

If the users can define the key of a thing and details about that I can use the daily audit file to transpose this information.

I just wanted to make sure that my thoughts were not clouded by preconcieved notions or by lack of knowledge about new techniques.

Thank you|||What you are talking about is known as an EAV (Entity/Attribute/Value) model, and while it is occasionally appropriate, it is very difficult to write code around and I would NEVER recommend it for a "data warehouse".

If you need an unstructured data schema, consider developing in SQL Server 2005 and using the new XML datatype instead of an EAV design.|||Thank You BlindMan for putting a name to my problem. (EAV)
Thank You Brett

I am only using this struture to store an audit trail of a dynamic data structure.

I will persuade the users better to define there business needs so that I may make a true Data Warehouse.

I will use the Audit trail data and evaluate the rows of data that I recieve nighlty to populate the Warehouse. From predifined specs.

I cannot force a change in the data entering the Database.

But once here it is mine all mine.. AH HA HA HA :D|||I think you need to rethink your audit trail. If you are trying to use a single table to store all data changes from any other table, you are going to find the resulting dataset quite unwieldy. Either just store a description of the change that occured, or create separate archive tables for each production to table to store a history of modifications.|||Thank You BlindMan for putting a name to my problem. (EAV)have a look at tony andrews' article OTLT and EAV: the two big design mistakes all beginners make (http://tonyandrews.blogspot.com/2004/10/otlt-and-eav-two-big-design-mistakes.html)

tony's another dbforums stallwart|||To tell the truth...for me, doing audits...simpler is better

Just have an exact copy of the table.

Add 3 columns, HIST_ADD_BY, HIST_ADD_DT, HIST_ADD_TYPE

Create a trigger that inserts into this table for all UPDATE and DELETE Operations and move the entire row

Put no indexes on this table

Boom, audit done

If you want performance on analysis, I'd reccomend that you bcp the data out and load it to a table with indexes (applied after the load)

I would not want to interfere with the triggers at all

MOO|||Thanks all for the reference to the column.

The EAV I am forced to use is a decision of My Management and cannot push them off of that concept. Oh the fate of a peon. I have explained the pros and cons of this decision but this is what has been decided.

The other option that they suggested was to dynamically evaluate the key fields and if a new one appears generate the DDL to add a field to a table of 800+ fields and transpose this data.

They wish to make the data flexible for any forseeable senario without further IT involvment.

If I had total control ....|||They wish to make the data flexible for any forseeable senario without further IT involvment.lol
I've been enjoying the evolution of this thread. I love it when threads like this end with the management concluding that they can conceive of a model that will require no "further IT involvment".

I've never had the misfortune to run into a full blown EAV model (appropriately implemented or not) in the flesh but it's pretty clear with only a little reading and even a substandard imagination like mine that this is precisly where they do not lead you.

Pro - can stick any data in the db
Con - can stick any data in the db
Con - Try getting it out again

"for any forseeable senario" lol.

Ah well - you tried. Best of luck :D|||Put it in writing/e-mail right now that you think XML is the way to go with this. Then save a copy of the document in your CYA file.
Some very complex coding is ahead of you.|||committing to writing that XML is the way to go may backfire on ya...

not that i've got any XML experience, but i've heard horror stories about performance, and since XML has such cachet with management, they may take you up on it and then you could be cooked|||Yes, the performance sucks compared with a standard normalized database, but is probably no worse than an EAV design and with a helluva lot less programming. I would not place data in an XML column unnecessarily, but would reserve it only for data that could not be predefined in the business model.

Database Design Standards

Well i've been given a big job of copying all the databases from an old
server to a new server. In order to provide better security, availabilty,
performance.
My servers are in a DMZ, so i have to use remote desktop/terminal services
to connect to it.
1. I have two logical partitions in the server. Is it a good practice to
store the OS and SQL server software itself on C:\ and all the data on
d:\??(Will it help me in anyways to achieve better performance? Can i
make separate directories for each databaseon d:\. and further on extending
it to sub directories for data and log files?
2. Should i copy all objects such as logins, DB plans, jobs etc. from the
old server or is it a better a practice to start all the plans over (create
new plans) to achieve better results and only copy the databases?
3. What is a good strategy for backup plans? For Log Files? For Primary
Files?
4. How to come up with a good Disaster Recovery Plan? What are all the
things you need to have in order to create a good DR plan? what is a good
way to test it?
5. What is the best way to secure SQL server? Who should have what
access? Which people should have access to the server itself? And how can
i give people read only access to the databases if they have access to the
server? Do they even need access to the server? How can they only have
read access to the SQL server databases? What tools do i need? Since i
have to use remote desktop to conncet to the servers, how can i give my
clients that just want read access to the all the data files including log
files? What do they need installed / or use in order to achieve this?
6. Is there any way you can come up with Roles scheme for certain users?
Lets say a particular group of users should have a certain permissions? Can
we create a something like that? that need to be done on the OS level
rather than SQL level.?
I know this is asking for a lot, but its really important to me, your
valuable knowledge on all this issues would be much much appreciated?
Thank you guys very much
NO HELP So far
"Shash Goyal" <Shash703@.gmail.com> wrote in message
news:ejQCy58tEHA.348@.tk2msftngp13.phx.gbl...
> Well i've been given a big job of copying all the databases from an old
> server to a new server. In order to provide better security, availabilty,
> performance.
> My servers are in a DMZ, so i have to use remote desktop/terminal services
> to connect to it.
> 1. I have two logical partitions in the server. Is it a good practice to
> store the OS and SQL server software itself on C:\ and all the data on
> d:\??(Will it help me in anyways to achieve better performance? Can i
> make separate directories for each databaseon d:\. and further on
extending
> it to sub directories for data and log files?
> 2. Should i copy all objects such as logins, DB plans, jobs etc. from
the
> old server or is it a better a practice to start all the plans over
(create
> new plans) to achieve better results and only copy the databases?
> 3. What is a good strategy for backup plans? For Log Files? For Primary
> Files?
> 4. How to come up with a good Disaster Recovery Plan? What are all the
> things you need to have in order to create a good DR plan? what is a
good
> way to test it?
> 5. What is the best way to secure SQL server? Who should have what
> access? Which people should have access to the server itself? And how
can
> i give people read only access to the databases if they have access to the
> server? Do they even need access to the server? How can they only
have
> read access to the SQL server databases? What tools do i need? Since i
> have to use remote desktop to conncet to the servers, how can i give my
> clients that just want read access to the all the data files including log
> files? What do they need installed / or use in order to achieve this?
> 6. Is there any way you can come up with Roles scheme for certain users?
> Lets say a particular group of users should have a certain permissions?
Can
> we create a something like that? that need to be done on the OS level
> rather than SQL level.?
> I know this is asking for a lot, but its really important to me, your
> valuable knowledge on all this issues would be much much appreciated?
> Thank you guys very much
>
|||On Sun, 24 Oct 2004 23:45:32 -0500, Shash Goyal wrote:

>NO HELP So far
Hi Shash,
There are everal replies in some of the other groups wherre you posted
this same question. I recommend you follow up on those replies instead of
complaining about lack of replies in this grooup.
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)
|||hi,
"Shash Goyal" <Shash703@.gmail.com> ha scritto nel messaggio
news:ejQCy58tEHA.348@.tk2msftngp13.phx.gbl
big deal, isn't it? =;-D

> Well i've been given a big job of copying all the databases from an
> old server to a new server. In order to provide better security,
> availabilty, performance.
> My servers are in a DMZ, so i have to use remote desktop/terminal
> services to connect to it.
> 1. I have two logical partitions in the server. Is it a good
> practice to store the OS and SQL server software itself on C:\ and
> all the data on d:\??(Will it help me in anyways to achieve better
> performance? Can i make separate directories for each databaseon
> d:\. and further on extending it to sub directories for data and log
> files?
I usually go this way on desktops... just for a schema order where data is
not directly bound and mixed with exes...
you do not gain better performance as drive and controller are the same..
perhaps you could get worser performance as the disk headers will have more
work... but for sure you do not gain benefits this way..
you are not granted against disk failures as one of them wil probably trash
exes and data..
again.. I do it myself the same way.. but only for a schema mapping order,
not for physical matters..
to achieve better througoutput performance, you should go for separate
controllers and drives... RAID solutions as well for improving security...
further basic info about RAID levels at http://www.acnc.com/04_00.html
as regard te second part of the question, yes, you can... no problem with
that..

> 2. Should i copy all objects such as logins, DB plans, jobs etc.
> from the old server or is it a better a practice to start all the
> plans over (create new plans) to achieve better results and only copy
> the databases?
I do not think you'll get problems copying all original objects to the new
server... I see non penalties in that... yo could just get orphaned objects
if your original server is not clean, but I do not see problems at all..

> 3. What is a good strategy for backup plans? For Log Files? For
> Primary Files?
hey, this is trickie... you have to think about your own needs... there' no
one size fits all strategy... depending on your needs you could be happy
with a dayly full backup for a little database, even a weekly full backup
for a quite read-only database..
if you are subscriber at SQL Server Magazine, you can have a look at good
articles like
http://www.windowsitpro.com/Article/...647/39647.html
http://www.windowsitpro.com/Article/...657/39657.html
this is free to read,
http://www.winnetmag.com/Article/Art...915/25915.html , for Very Large
Databases secenarios, with full, differential an log backup features
explanations..
again... it all depends on your data, your needs, your shadow time limits...
http://www.winnetmag.com/Article/Art...340/24340.html is free too...
by "Notre Dame SQL Server", Kalen Delaney

> 4. How to come up with a good Disaster Recovery Plan? What are all
> the things you need to have in order to create a good DR plan? what
> is a good way to test it?
same as above... plus add OS, cluster settings, applications CD to the
recovery schema...
a disaster can strike you down to your knees, so you'll have all (really
all) to start a new database server, application server, web server, farm
and all..
so, to your standard backups tapes, you should add all the CDs to install
and ugrade to your current service pack levels your OS and applications..
and please do not store them on the main server top =;-D
you should consider how important is your data and how you want to protect
all your IT scenario.. you can perhaps maintain a local copy and dayly ship
a backup copy to your bank or to specialised storing company..
it's a matter of costs, requirements and so on...

> 5. What is the best way to secure SQL server? Who should have what
> access? Which people should have access to the server itself? And
> how can i give people read only access to the databases if they have
> access to the server? Do they even need access to the server?
> How can they only have read access to the SQL server databases?
> What tools do i need? Since i have to use remote desktop to conncet
> to the servers, how can i give my clients that just want read access
> to the all the data files including log files? What do they need
> installed / or use in order to achieve this?
only users needing access to the data should be given right to access the
database server.. and only to the databases they need to access, with the
minimal privileges they need for theyr required activities..
the tool you need to implement security depends on your skill... Query
Analyzer could be enought to execute GRANT/DENY DCL statements to database
objects, where sp_addlogin/sp_grantlogin are required for server accces..
and again, give them only access (via sp_adduser) to the database they need
to access..
there's no readonly privilege to the database.. you are legitimated to
access it or not... you can give readonly privileges to tables and views
objects granting SELECT only privileges to some or all of them, but my
preferred access schema is via GRANT EXECUTE to
retrival/insert/update/delete stored procedures only and DENY all privileges
on table objects.. you can give them access to view object if needed..
a good starting point about secuirty and some best practice can be found at
http://www.sql-server-performance.co...l_security.asp , as long as
http://www.microsoft.com/technet/pro.../sp3sec03.mspx
...
you users do not need access to the physical files of your databases, nor do
they need access to the log files at all.. your database are only logical
matters for them, and this should remain that way..
they only need the application(s) they use to interact with data, both
windowsform or web interfaces, and, usually MDAC, in order to provide the
connectivity tools and SQL Server drivers.. not more, not less.. standar
users do not need acces to Enterprise Manager and/or Query Analyzer.. give
them only what they really need.. not more.. better less =;-D

> 6. Is there any way you can come up with Roles scheme for certain
> users? Lets say a particular group of users should have a certain
> permissions? Can we create a something like that? that need to be
> done on the OS level rather than SQL level.?
this is a best practice and standard idea.. instead of maintaining
thousounds of users privileges, create at database level different roles..
make each user part of the corresponding role and manage privileges at role
level... you will not become insane and you can achieve the granularity you
usually need..
roles have to be managed at database level, and are known as user defined
database roles... not at the OS level... roles at OS level can be usefull,
but you have to deal with database and related security...
have a look at
http://msdn.microsoft.com/library/de..._addp_33s5.asp

> I know this is asking for a lot, but its really important to me, your
> valuable knowledge on all this issues would be much much appreciated?
do you mean you don't know if our meanings will be appreciated? ROTFL
you are right... no one but you knows better your own needs ... I can only
give you some hints based on my own experience and based on my (poor) skill,
but you have the key of your success in this area..
good luck
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.9.1 - DbaMgr ver 0.55.1
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Thank you very much Andrea!!!
"Andrea Montanari" <andrea.sqlDMO@.virgilio.it> wrote in message
news:2u6on1F26o6hvU1@.uni-berlin.de...
> hi,
> "Shash Goyal" <Shash703@.gmail.com> ha scritto nel messaggio
> news:ejQCy58tEHA.348@.tk2msftngp13.phx.gbl
> big deal, isn't it? =;-D
>
> I usually go this way on desktops... just for a schema order where data is
> not directly bound and mixed with exes...
> you do not gain better performance as drive and controller are the same..
> perhaps you could get worser performance as the disk headers will have
more
> work... but for sure you do not gain benefits this way..
> you are not granted against disk failures as one of them wil probably
trash
> exes and data..
> again.. I do it myself the same way.. but only for a schema mapping order,
> not for physical matters..
> to achieve better througoutput performance, you should go for separate
> controllers and drives... RAID solutions as well for improving security...
> further basic info about RAID levels at http://www.acnc.com/04_00.html
> as regard te second part of the question, yes, you can... no problem with
> that..
>
> I do not think you'll get problems copying all original objects to the new
> server... I see non penalties in that... yo could just get orphaned
objects
> if your original server is not clean, but I do not see problems at all..
>
> hey, this is trickie... you have to think about your own needs... there'
no
> one size fits all strategy... depending on your needs you could be happy
> with a dayly full backup for a little database, even a weekly full backup
> for a quite read-only database..
> if you are subscriber at SQL Server Magazine, you can have a look at good
> articles like
> http://www.windowsitpro.com/Article/...647/39647.html
> http://www.windowsitpro.com/Article/...657/39657.html
> this is free to read,
> http://www.winnetmag.com/Article/Art...915/25915.html , for Very
Large
> Databases secenarios, with full, differential an log backup features
> explanations..
> again... it all depends on your data, your needs, your shadow time
limits...
> http://www.winnetmag.com/Article/Art...340/24340.html is free too...
> by "Notre Dame SQL Server", Kalen Delaney
>
> same as above... plus add OS, cluster settings, applications CD to the
> recovery schema...
> a disaster can strike you down to your knees, so you'll have all (really
> all) to start a new database server, application server, web server, farm
> and all..
> so, to your standard backups tapes, you should add all the CDs to install
> and ugrade to your current service pack levels your OS and applications..
> and please do not store them on the main server top =;-D
> you should consider how important is your data and how you want to protect
> all your IT scenario.. you can perhaps maintain a local copy and dayly
ship
> a backup copy to your bank or to specialised storing company..
> it's a matter of costs, requirements and so on...
>
> only users needing access to the data should be given right to access the
> database server.. and only to the databases they need to access, with the
> minimal privileges they need for theyr required activities..
> the tool you need to implement security depends on your skill... Query
> Analyzer could be enought to execute GRANT/DENY DCL statements to database
> objects, where sp_addlogin/sp_grantlogin are required for server accces..
> and again, give them only access (via sp_adduser) to the database they
need
> to access..
> there's no readonly privilege to the database.. you are legitimated to
> access it or not... you can give readonly privileges to tables and views
> objects granting SELECT only privileges to some or all of them, but my
> preferred access schema is via GRANT EXECUTE to
> retrival/insert/update/delete stored procedures only and DENY all
privileges
> on table objects.. you can give them access to view object if needed..
> a good starting point about secuirty and some best practice can be found
at
> http://www.sql-server-performance.co...l_security.asp , as long as
>
http://www.microsoft.com/technet/pro.../sp3sec03.mspx
> ..
> you users do not need access to the physical files of your databases, nor
do
> they need access to the log files at all.. your database are only logical
> matters for them, and this should remain that way..
> they only need the application(s) they use to interact with data, both
> windowsform or web interfaces, and, usually MDAC, in order to provide the
> connectivity tools and SQL Server drivers.. not more, not less.. standar
> users do not need acces to Enterprise Manager and/or Query Analyzer.. give
> them only what they really need.. not more.. better less =;-D
>
> this is a best practice and standard idea.. instead of maintaining
> thousounds of users privileges, create at database level different roles..
> make each user part of the corresponding role and manage privileges at
role
> level... you will not become insane and you can achieve the granularity
you
> usually need..
> roles have to be managed at database level, and are known as user defined
> database roles... not at the OS level... roles at OS level can be usefull,
> but you have to deal with database and related security...
> have a look at
>
http://msdn.microsoft.com/library/de..._addp_33s5.asp
>
> do you mean you don't know if our meanings will be appreciated? ROTFL
> you are right... no one but you knows better your own needs ... I can only
> give you some hints based on my own experience and based on my (poor)
skill,
> but you have the key of your success in this area..
> good luck
> --
> Andrea Montanari (Microsoft MVP - SQL Server)
> http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
> DbaMgr2k ver 0.9.1 - DbaMgr ver 0.55.1
> (my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
> interface)
> -- remove DMO to reply
>

Database Design setup

I have an application that lets users upload pictures. These pictures are
stored in different folders depending on the user ID (of the user that it
belongs to). The path can be figured out dynamically by knowing the user
ID. However, the programmer that's coding my application has decided to
save the full path into the database.
Upside that I see is, if there's a huge load of traffic I can see how it may
be good for performance, since you don't need to dynamically figure out the
path.
The downside though, is that this leads to database bloat, and I'm not sure
if that will cause the database performance to decrease. Also, whenever the
system path is updated, a script needs to go through the database and update
everything to reflect the new path.
So, if you can give me your input on this, I'd greatly appreciate it. Is
this a good, or bad way of designing a database?Sounds like you only need to store the full path once per user. It seems
sensible to put the path in a Users table in your database. Storing the full
path against every picture would be inefficient and also may be inconvenient
if you ever need to change the file location.
--
David Portas
SQL Server MVP
--|||I agree with David, Save the directory in the User row... If you figure our
the path on the fly based on the userid, your are locked into the file
location. If you simply store it in the database, you can change it very
easily.
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Shabam" <blislecp@.hotmail.com> wrote in message
news:G5Gdnfwf89eRJsvcRVn-ow@.adelphia.com...
> I have an application that lets users upload pictures. These pictures are
> stored in different folders depending on the user ID (of the user that it
> belongs to). The path can be figured out dynamically by knowing the user
> ID. However, the programmer that's coding my application has decided to
> save the full path into the database.
> Upside that I see is, if there's a huge load of traffic I can see how it
may
> be good for performance, since you don't need to dynamically figure out
the
> path.
> The downside though, is that this leads to database bloat, and I'm not
sure
> if that will cause the database performance to decrease. Also, whenever
the
> system path is updated, a script needs to go through the database and
update
> everything to reflect the new path.
> So, if you can give me your input on this, I'd greatly appreciate it. Is
> this a good, or bad way of designing a database?
>
>|||"Shabam" <blislecp@.hotmail.com> wrote in message
news:G5Gdnfwf89eRJsvcRVn-ow@.adelphia.com...
> Upside that I see is, if there's a huge load of traffic I can see how it
may
> be good for performance, since you don't need to dynamically figure out
the
> path.
Two good rules of thumb: 1) Don't duplicate, and 2) Premature optimization
is the root of all evil.
Make it work right, then make it work fast (or small). It's surprising how
infrequently the second step is required.|||> Two good rules of thumb: 1) Don't duplicate, and 2) Premature optimization
> is the root of all evil.
> Make it work right, then make it work fast (or small). It's surprising how
> infrequently the second step is required.
I've heard different schools of thought though. One says that hardcoding
the path makes it quicker because #1, there's no need for an additional
query to get the path variables, and #2, there's no additional processing
needed to put it all together. And if an update were ever needed all I need
is one query to update them all.
However, it does add to the database bloat. Does that affect performance?|||> However, it does add to the database bloat. Does that affect performance?
Yes, which is why your argument doesn't make much sense.
--
David Portas
SQL Server MVP
--|||> Yes, which is why your argument doesn't make much sense.
Can you show me an article that talks about this downside?