Showing posts with label scenario. Show all posts
Showing posts with label scenario. Show all posts

Tuesday, March 27, 2012

Database help

hii have a DB scenario, it may be basic to u, but i am new to this so plz explain in details or if you can provided links to related articles that will be great.

i have sql server 2000 and i am using dataset on my asp.net application. now as Dataset is connenctionless, what will happen if i have filled my dataset with some records from database and updated those records in dataset. in that time some other user deleted some of those records from database. now when i will try to batch update database using my dataset (with records that has been deleted from DB) what will happen? will i get an exception or what. plz explain in detail . any links to articles will be great.

my second question is same, what are the methods to lock database if one user is accessing (updating) one record, so that other user dont get to change it at the same time? do i have to manage it in Database or what.

thank you in advance

regards

Hi,

I think this article will explain a lot

http://www.asp.net/learn/data-access/tutorial-21-vb.aspx

|||

Hi zeeshannasir,

now as Dataset is connenctionless, what will happen if i have filled my dataset with some records from database and updated those records in dataset. in that time some other user deleted some of those records from database.

My question is: what do you mean by "dataset is connectionless"? Do you mean that your database has been detached in your database engine? Well,in that case your database won't be accessible at all so you(and all the other users) cannot modify your database.

As to your second quesion, actually you don't have to worrry about it.All the transactions in SQL has been designed to comply with theACID (Atomicity ,Consistency, Isolation Durability) compliance.For example, if user A is currently opening up and reading the info. of a particular database, and meanwhile, user B is trying to open up the same database. Since there is no modification being made to the database, user B is allowed to open up. However, if user A is writting new data to the database, all the operations user B makes will be denied.

Hope my suggestion helps

|||

hi Bo Chen

what i meant by "dataset is connectionless" is that, i filled my dataset with required data using a stored procedure. now i am not connected to database, plz correct me if i am wrong. any changes i made to dataset is local until i dont batch update manually, is it correct. now what will be the scenario if this is the case, i have filled my dataset and made some changes and while i was doing that someone else also access the same database and changed some of the records.

plz correct me if i am wrong

thanks

Wednesday, March 7, 2012

Database Design- Referencing multiple database

Hi All,
I am designing database where few of the master tables will reside in different database or in case different server. Scenario is
Server "A" with Database "A" may host the "Accounts" table.
Server "B" with Database "B" may host the "Product" table.
I am designing database "Project" which will hosted in Server "A".
My application requires this master tables [readonly access] as data inserted in my application refers this tables. Also there are reports to be generated which refer this tables.
How do i design my database and sql queries?
I am thinking of approach of having equivalent tables created in my database and writing service which keep tables in my database in sync. This will ensure good perfomance during transaction and reports as they will need to refer this table locally as opposed to different database or different server.

Any thoughts on above approach?? or any better/standard way for such scenarios ?

Thanks in Advance. Your inputs will be of great help.why multiple databases? It makes it harder to enforce referential integrity and it can cause other headaches. i just recently ran into an issue where i swapped out a database instead of doinng a restore and the application broke because database objects that reference another database actually store the database id instead of the name. it was easy to fix but I still had an hour of down time. thank god it was not a production server.|||Hi All,
Hi.
Hi All,
I am designing database where few of the master tables will reside in different database or in case different server.
Really...
Scenario is
Server "A" with Database "A" may host the "Accounts" table.
Server "B" with Database "B" may host the "Product" table.
I am designing database "Project" which will hosted in Server "A".
How do i design my database and sql queries?
In a word: "poorly".
I am thinking of approach of having equivalent tables created in my database and writing service which keep tables in my database in sync. This will ensure good perfomance during transaction and reports as they will need to refer this table locally as opposed to different database or different server.
Well, that plan certainly is......"creative"...
Any thoughts on above approach?? or any better/standard way for such scenarios ?
I'd say, practically anything else would be better.
Thanks in Advance. Your inputs will be of great help.
No problem.|||Ahh, the much-vaunted (but almost certainly mythical and definitely undocumented) 'unreplication' functionality of SQL Server! ;)

On a more serious note, if you really want to proceed down this route you will need to set up Linked Servers and enable the MSDTC service.

I would implore you to think again.

Lempster|||That's certainly a novel approach - doomed but novel. Out of curiosity what advantages were you expecting from spreading your system across different servers? and what was your database(s) supposed to hold?|||How versatile

but, um, how much experience do you have?

Oh, I get it, you're in upper manglement|||Ouch Brett...that'll likely leave a scar. ;)

I assumed from the description that between the lines there is a plain motivation. Seems to me that the distant (aka remote) databases are already in existance, and the O.P. has been given a task to pull some data in from other servers, and followed the logical path to the current planned implementation!

Sheesh. How silly is it to have databases spread all 'round when you can just copy them all to one place and just keep them in synch. ?|||Hi All,
I am designing database

I didn't read that all

I designing a housebuilding business

I plan to have all of my nails located in DC, all of my wood in Oregon, all the fixtures in NY, and all of my roofing supplies in N'orleans (There all over the place and free)|||sometimes i go to other sql boards after following a link and i am always surprised at the difference in the content from this place.|||how so?

too short|||i think this board has more of a tendency to slam the OP.|||Nothing like the real world, eh|||No soup for you, poster!|||There are scenarios where distributed databases are a good idea - but they don't come up very often (at least I've never met one). Must admit it would be quite interesting to work on one though. I think it's important to hear the reasoning behind his system and find out why he thinks it's so versatile.|||I agree there, Mike. Sometimes you need to know the rationale behind the current design before dashing said design upon the jagged and bloody rocks of despair. ;)

If nothing else, it also allows one to more pointedly help (and/or taunt) the original poster's assumptions and reasoning.

As I am sure you are aware, sometimes stuff just comes across initially so far off the wall it's hard to resist a good-natured jab in the ribs and perhaps a well-intentioned kick in the groin.|||Hi all,
Thanks for all kinds of replies.
Well first let me clear (which i shud have done in my first post.) , that database are hosted on diff machine coz they are mastered by diff groups of ppl or the department. Application which we will be designing depends on these data. We cannot certainly have all required data in one single database.
Option of creating creating identical tables and syncing regularly is as i feel the better than writing down the distributed queries.

Any thought on it ??
Thanks,|||Hi all,
Thanks for all kinds of replies.
Well first let me clear (which i shud have done in my first post.) , that database are hosted on diff machine coz they are mastered by diff groups of ppl or the department. Application which we will be designing depends on these data. We cannot certainly have all required data in one single database.
Option of creating creating identical tables and syncing regularly is as i feel the better than writing down the distributed queries.

Any thought on it ??
Thanks,|||What's wrong with just downloading the data from the other data sources via feeds - bcp each file into a transfer table - check the data - put the changed data into your database. How many feeds could you expect this way, what size (roughly) for each feed?

Your method may save you having to write any feeds but the people writing the app are going to hate you for the rest of their lives :)

Mike|||Well first let me clear (which i shud have done in my first post.) , that database are hosted on diff machine coz they are mastered by diff groups of ppl or the department.This sounds like a small data warehousing initiative to me. Perhaps that is the approach you should be taking.|||We do stuff like this on a daily basis. Consolidating data from different departments on a single machine for historical and modeling purposes. I use a combination of distributed queries and web services that allow us to yank data in flat file format from some machines, and yank data directly from others (via linked servers).

Seems like downloading and synching databases is alot more work than you need to be doing to do what (i understand to be...) you need to do. Data feeds and distributed queries are much better with respect to basic database design conventions, and synching databases just causes a spontaneous sphincter constriction whenever I hear it.

Duplication of data = bad. Direct/indirect (and on-demand) access to remote data = good.

Sounds like you've already decided though, so g'luck to you :)|||Well the things getting more complex. We will be having four external database to depends on for our application.
Reason of staying away from distributed query was that our application requires this data (external database table serves as master table for our application) in the transactions. And of course in reports as well.

I liked the suggestion of getting feed from external database into temporary staging area and then updating only updating the changesets in our tables.|||Originally posted by versatile_me
I liked the suggestion of getting feed from external database into temporary staging area and then updating only updating the changesets in our tables.I'd like to claim first dibs on the concept but I suspect it's been around for 40 years.

I know it's fun comming up with new systems but after you spend 6 months sweating blood trying to get it to work there are only a few possible outcomes :
it fails and you have to call in a professional who is then faced with working with a flawed design or loosing the client by throwing everything away and starting afresh.
it works, but only just, and after 3 months limping along the system gets abandonded.
it works and is a fantastic success - I'm afraid this is the least likely outcome :)
If the application is at all important to your company then it may well be worth getting an experienced profesional in to do the work and you provide the business requirements. This would be a good way to learn about database/system design and also might ensure any good ideas you may have will appear in the finished product.

Mike|||We do stuff like this on a daily basis. Consolidating data from different departments on a single machine for historical and modeling purposes. I use a combination of distributed queries and web services that allow us to yank data in flat file format from some machines, and yank data directly from others (via linked servers).

Seems like downloading and synching databases is alot more work than you need to be doing to do what (i understand to be...) you need to do. Data feeds and distributed queries are much better with respect to basic database design conventions, and synching databases just causes a spontaneous sphincter constriction whenever I hear it.

Duplication of data = bad. Direct/indirect (and on-demand) access to remote data = good.

Sounds like you've already decided though, so g'luck to you :)

...
I am thinking of approach of having equivalent tables created in my database and writing service which keep tables in my database in sync. This will ensure good perfomance during transaction and reports as they will need to refer this table locally as opposed to different database or different server.

I'm struggling to see much difference between TallCowboy's "daily consolidation" and the OP's idea of equiv. Master tables that are regularly refreshed.

Although duplicate data = bad, isn't it common practice to have read-only replicated tables on a different server for reporting (or other read-only) purposes? Obviously; the data is as old as the last replication so the designer has to consider the ramification of slightly old data, but this localizes remote-connection / design breakages into the DTS / Copy programs, not the report.

Not so much "versitile" as "stable". (at least - until the source system changes and you have to fix the DTS - or retest it each and every time it changes ... so I'm not saying it's a great idea, just maybe unavoidable).|||I'm struggling to see much difference between TallCowboy's "daily consolidation" and the OP's idea of equiv. Master tables that are regularly refreshed.The difference is that in my system the data is not imported on a daily basis "as-is", but rather the existing tables are updated with NEW data that we did not previously have. However, I see your point in that the difference may be perception (and/or semantics) and my understanding of what the O.P. is contemplating as an implementation.

In my world, the data we import (via web service or via remote access) is not a "synching" of databases. It's the importation of data from external providers, and placed into our own "consolidated" and normalized database tables (and used for our own devious purposes completely unrelated to the original source(s) of the data). At least in my eyes, a completely different process than importing actual tables from a remote database and keeping them in synch.

Although duplicate data = bad, isn't it common practice to have read-only replicated tables on a different server for reporting (or other read-only) purposes? Obviously; the data is as old as the last replication so the designer has to consider the ramification of slightly old data, but this localizes remote-connection / design breakages into the DTS / Copy programs, not the report. I can't speak for this one, because we don't do it. We either provide access to our data via controlled (read-only) linked servers and associated userid's, or via a web service that is a front-end to our database.

We absolutely don't allow uncontrolled access to our tables, even remote access via linked servers/userid's is typically controlled with a view. If there is time and/or the longevity of the projects dictates, we write a web service wrapper to the external world and make them keep their nasty little grubbies off our databases.

We expect (and generally require) external/remote databases to have (or support) the same indirect access. We don't want our applications failing because they changed a table on the external system.

Not so much "versatile" as "stable". (at least - until the source system changes and you have to fix the DTS - or retest it each and every time it changes ... so I'm not saying it's a great idea, just maybe unavoidable).ed-zachary :)|||i think this board has more of a tendency to slam the OP.

Really?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=67782&whichpage=8|||ROTFLMAO ... like Mastercard ... that was priceless :D

Sunday, February 19, 2012

Database Design

Hi,
I'm designing a database with this scenario:
Our application will be used in big organization that each organization has
some sub-organizations. Each sub-organization has divisions(each division
can be beneath another division or beneath a sub-organization directly),
each division has roles and each role has employees:
Main Org >> Sub-Org >> Divisions >> Roles >> Employees
I use adjacency model (like Employee-ReportsTo fields) to handle the chart.
I think there is two main solutions for physical implementation of tables:
1) Creating separate tables for each level: tblSubOrg, tblDevisions,
tblRoles, tblEmployees
Then create another table that keeps the hierarchy information.
2) Creating one table for all of these entities and having all required
fields in that.
Both solutions can help to retrieve the chart but the first one needs an
extra join to get more information about each entity, but the second one
does not need. First solution looks pretty nice but I'm just worried about
it's performance as the tables become larger.
Any help would be greatly appreciated.
LeilaIn SQL, there are no operators which can act on an adjacency list directly
to explode a hierarchy ( treesort etc. ). So, you will end up writing a lot
of procedural code ( loops, recursion etc. ) to retrieve the data. A popular
approach is to transform the adjacency list to a nested model where you
represent the nodes in the hierarchy using two additional attributes, left &
right. Search the google archives for "nested sets" and you will find Joe
Celko's examples in this regard.
--
Anith|||Thanks Anith,
I read that article but I cannot understand that what Right and Left
indicate for each row? Please help me.
Thanks..
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:e0DbEzS6EHA.1524@.TK2MSFTNGP09.phx.gbl...
> In SQL, there are no operators which can act on an adjacency list directly
> to explode a hierarchy ( treesort etc. ). So, you will end up writing a
lot
> of procedural code ( loops, recursion etc. ) to retrieve the data. A
popular
> approach is to transform the adjacency list to a nested model where you
> represent the nodes in the hierarchy using two additional attributes, left
&
> right. Search the google archives for "nested sets" and you will find Joe
> Celko's examples in this regard.
> --
> Anith
>|||"Leila" <Leilas@.hotpop.com> wrote in message
news:%23eOiFCU6EHA.824@.TK2MSFTNGP11.phx.gbl...
> Thanks Anith,
> I read that article but I cannot understand that what Right and Left
> indicate for each row? Please help me.
> Thanks..
Leila,
Pretend that you have the following hierarchy:
a
/ \
b c
\
d
Now, starting at 'a' and walking left, you're going to increment every time
you hit a node from the left, and every time you hit it from the right:
1 a 8
/ \
2 b 3 4 c 7
\
5 d 6
... and that is what the 'left' and 'right' represent.
This makes it very easy to write hierarchical queries. For instance, to get
all children of C, we simply query WHERE lft > 4 AND lft < 7.
See Celko's posts for many more examples.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--|||Thanks Adam, I got it :-)
But it seems difficult to retrieve nodes only one level lower than a
particular node?
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:Onv8VfX6EHA.3828@.TK2MSFTNGP09.phx.gbl...
> "Leila" <Leilas@.hotpop.com> wrote in message
> news:%23eOiFCU6EHA.824@.TK2MSFTNGP11.phx.gbl...
> > Thanks Anith,
> > I read that article but I cannot understand that what Right and Left
> > indicate for each row? Please help me.
> > Thanks..
> Leila,
> Pretend that you have the following hierarchy:
> a
> / \
> b c
> \
> d
> Now, starting at 'a' and walking left, you're going to increment every
time
> you hit a node from the left, and every time you hit it from the right:
> 1 a 8
> / \
> 2 b 3 4 c 7
> \
> 5 d 6
> ... and that is what the 'left' and 'right' represent.
> This makes it very easy to write hierarchical queries. For instance, to
get
> all children of C, we simply query WHERE lft > 4 AND lft < 7.
> See Celko's posts for many more examples.
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>|||"Leila" <Leilas@.hotpop.com> wrote in message
news:eh6HGsZ6EHA.796@.TK2MSFTNGP09.phx.gbl...
> Thanks Adam, I got it :-)
> But it seems difficult to retrieve nodes only one level lower than a
> particular node?
Yes, that's one of the downfalls of the system, IMO. Celko has some queries
in his examples that show how to do it, but some people like to keep both
the adjacency list and the nested sets around simultaneously in order to
make situations like that a lot easier... It's a tradeoff of space vs. ease
of use.
--
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--|||On Fri, 24 Dec 2004 12:59:09 +0330, Leila wrote:
>Thanks Adam, I got it :-)
>But it seems difficult to retrieve nodes only one level lower than a
>particular node?
Hi Leila,
I think you'd need to do something like this:
SELECT Parent.name, Child.name
FROM Hierarchy AS Parent
INNER JOIN Hierarchy AS Child
ON Child.lft BETWEEN Parent.lft AND Parent.rgt
WHERE NOT EXISTS
(SELECT *
FROM Hierarchy AS Intermediate
WHERE Intermediate.lft BETWEEN Parent.lft AND Parent.rgt
AND Child.lft BETWEEN Intermediate.lft AND Intermediate.rgt)
(untested)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||Thanks, I'll test it!
"Hugo Kornelis" <hugo@.pe_NO_rFact.in_SPAM_fo> wrote in message
news:jqaos09nuh4vjdcej0lve888q13ij48gj6@.4ax.com...
> On Fri, 24 Dec 2004 12:59:09 +0330, Leila wrote:
> >Thanks Adam, I got it :-)
> >But it seems difficult to retrieve nodes only one level lower than a
> >particular node?
> Hi Leila,
> I think you'd need to do something like this:
> SELECT Parent.name, Child.name
> FROM Hierarchy AS Parent
> INNER JOIN Hierarchy AS Child
> ON Child.lft BETWEEN Parent.lft AND Parent.rgt
> WHERE NOT EXISTS
> (SELECT *
> FROM Hierarchy AS Intermediate
> WHERE Intermediate.lft BETWEEN Parent.lft AND Parent.rgt
> AND Child.lft BETWEEN Intermediate.lft AND Intermediate.rgt)
> (untested)
> Best, Hugo
> --
> (Remove _NO_ and _SPAM_ to get my e-mail address)|||To convert a nested sets model into an adjacency list model:
>> But it seems difficult to retrieve nodes only one level lower than a
particular node? <<
SELECT B.emp AS boss, E.emp
FROM OrgChart AS E
LEFT OUTER JOIN
OrgChart AS B
ON B.lft
= (SELECT MAX(lft)
FROM OrgChart AS S
WHERE E.lft > S.lft
AND E.lft < S.rgt);
Another way to think about what (lft,rgt) is that they are a count of
the tags in HTML, or begin-end pairs in a programming language or
parens in algebra.
What is really hard about the adjacency list model is writing the
constraints needed to prevent cycles and forests. Most people never
think about this and just do not bother. Well, that is until one of
their procedural traversals gets stuck in an endless loop.