[how to] Only one NULL for one part of primary key |
- Only one NULL for one part of primary key
- MySQL design problem
- Possible INDEX on a VARCHAR field in MySql
- How to improve INSERT speed in large table that has unique constraint
- Conditional Import
- How to view the current settings of Autovacuum in Postgres?
- Why is optimistic locking faster than pessimistic locking?
- How does optimistic locking actually enforce re-read/update?
- Implementation of stack in MYSQL
- Selecting with varbinary(max) criteria (in the where clause)
- UML class diagramm for database design?
- When to use identity increment?
- Unable to start Oracle Database Server : Get an error as I try to start it
- check constraint that has dynamic list
- Scheduling a backup in SQL Server 2005
- Can I run a Report Server and a Mirror server from a working Log Shipping secondary instance?
- which one is the fastest way of moving database form local to live server in sql server
- Backup failure in SQL Server 2005
- What are the advantages of a database design with single table for MtM relationships?
- Global locking for multi-master Oracle GoldenGate replication
- Slow query performance
- "Waiting for initial communication packet" error 0 in MySQL
- Firebird monitoring tables
- How to modify an update in Oracle so it performs faster?
- Get the rank of a user in a score table
Only one NULL for one part of primary key Posted: 02 Mar 2013 05:51 PM PST So,i have two date columns : "start date" and "finish date" EDIT: PeriodID | PersonID | StartDate | FinishDate 1...................1.............1/1/10.......10/1/10 And yes,"PersonID" is a foreign key. |
Posted: 02 Mar 2013 08:44 PM PST So I have nearly no experience in DB Design, so forgive me if I'm asking something super nooby and ridiculous :) Basically my issue is this. I have say an item I need to create, this item will be constructed from 3-4 types of objects, with multiple object instances. Basically as per below: My question is this, is there a way to dynamically generate Object 3 through MySQL. Like if field #3 shows Object 3.1 call that table, if it shows 3.2 call that instead. Similar to a constructor. Also is there a way for me to map related objects. For example, since everything is dependent on Object 1, I'd like to be able to call Object 1 and have it pull all related instance of Objects 2,3,4 related to that specific object. I was thinking of creating a separate table top hold primary keys of related objects, but I'm thinking there is probably a better way of doing that. Also I've read that I shouldn't use stored procedures, and instead do everything with code. Is that correct, because I would think for my model it would be more convenient and cleaner to just call on Object one, and have MySQL do all the joins internally and return a single completed object Thank you very much for your help!! |
Possible INDEX on a VARCHAR field in MySql Posted: 02 Mar 2013 06:57 PM PST I am working in a MySql database, with a table like this: ...and I need to make a lot of queries like this (with 5-10 strings in the list): There will be around 24.000.000 unique rows 1) Should I use a |
How to improve INSERT speed in large table that has unique constraint Posted: 02 Mar 2013 01:36 PM PST I have a simple MyISAM table: that is expected to have 10s of millions of rows (or even more) eventually. I noticed that as the number of rows in the table increases, insert statements start to take longer. This is expected, as the documentation states that "the size of the table slows down the insertion of indexes by log N, assuming B-tree indexes". I read in another question that System info: MySQL 5.1.67-0ubuntu0.10.04.1 Running on Linode VM with 512 MB RAM and quad-core processor |
Posted: 02 Mar 2013 12:15 PM PST I have 300+ flat files. I am importing/loading them using LOAD DATA LOCAL INFILE 'D:\MxxT\tot2098.TXT' INTO TABLE Twenty.F98 FIELDS TERMINATED BY '' lines terminated by '\r\n' ; on my MYSQL Server database. Each of 20 files makes 28 tables. I have a flag variable which is MachineType in all flat files. After import of 20 files. I have to do SET SQL_SAFE_UPDATES=0; DELETE FROM Twenty.F98 WHERE MachineType <>1; SELECT DISTINCT MachineType FROM Twenty.F98;
Thanks !! |
How to view the current settings of Autovacuum in Postgres? Posted: 02 Mar 2013 12:56 PM PST I've found a million examples of how to set Autovacuum's configuration settings, but can't seem to find how to list the current configuration. Postgres 9.1 is the version I'm most interested in. |
Why is optimistic locking faster than pessimistic locking? Posted: 02 Mar 2013 03:54 PM PST Both forms of locking cause a process to wait for a correct copy of the record if its currently in use by another process. With pessimistic locking, the lock mechanism comes from the DB itself (a native lock object), whereas with optimistic locking, the lock mechanism is some form of row versioning like a timestamp to check whether a record is "stale" or not. But both cause a 2nd process to hang. So I ask: why is optimistic locking generally considered faster/superior than pessimistic locking? And, are there are use cases where pessimistic is preferred over optimistic? Thanks in advance! |
How does optimistic locking actually enforce re-read/update? Posted: 02 Mar 2013 01:40 PM PST My understanding of optimistic locking is that it uses a timestamp on each record in a table to determine the "version" of the record, so that when the record is access by multiple processes at the same time, each has a reference to the record's version. Then, when an update is performed, the timestamp is updated. Before an update is committed, it reads the timestamp on the record a 2nd time. If the timestamp (version) that it has is no longer the timestamp on the record (because it's been updated since the first read), then the process must re-read the entire record and apply the update on the new version of it. So, if anything I have stated is not correct, please begin by making clarifications for me. But, assuming I'm more or less correct here... How does this actually manifest itself in a RDBMS? Is this 2nd read/verification enforced in the application logic (the SQL itself) or is it a tuning parameter/configuration that the DBA makes? I guess I'm wondering where the logic comes from to read the timestamp and perform a 2nd update if the timestamp is stale. So I ask: does the application developer enforce optimistic locking, or is it enforced by the DBA? Either way, how? Thanks in advance! |
Implementation of stack in MYSQL Posted: 02 Mar 2013 07:23 PM PST I had an abstract idea of implementing a stack in MYSql. Tried a lot of Google work but couldn't reach to any logical conclusion. The Stack must be a collection of tables with the stack top pointing at a particular table. We may have various such stacks in our DB. The stack length may increase if for example the field from the table is full. Likewise the stack length may decrease in the opposite manner! Could you please give me an implementation idea! is it really possible at first place??Hope im clear with my question :-P Please HELp!!!!! Thanks in advance! |
Selecting with varbinary(max) criteria (in the where clause) Posted: 02 Mar 2013 09:58 AM PST Basic info
Backround (skip if not interested): A project I'm maintaining uses an ORM, which apparently stored my enum values (which inherit from Byte) into binary serialized .Net objects stored in a varbinary(max) field. I only found out this was happening after a new requirement emerged dictating my code to run under medium trust. Since the .Net binary formatter needs full trust to be called, it started crashing on the enums. To clean the mess up I need to create migration scripts that will convert these (varbinary(max)) values back to integer values. There are only a handful of different values so it shouldn't be a big problem (I thought). The problem: I am able to get string representations of the blobs when selecting: It returns a string '0x...(an array of hexadecimal values)'. But when I try to select on the column using copy-and-paste making sure I have the exact binary equivalent: it does not return any records. So is it possible to solve this using a client (such as Management Studio)? If so, what would be the correct syntax? |
UML class diagramm for database design? Posted: 02 Mar 2013 08:18 AM PST I used to make database designs using a french method called MERIS that uses mainly two diagrams to create the database (MCD and MLD), then i heard about UML and that is used also for databases and not only for coding, i thought it has some special diagram for database design, but i noticed that some people use class diagram to make a database design, i find it not compatible with this because :
Question is : Is UML a nice choice for a database design ? |
When to use identity increment? Posted: 02 Mar 2013 06:57 AM PST Many times I face these three choices to work with IDs:
Question is: which choice do I make, and according to what criteria? |
Unable to start Oracle Database Server : Get an error as I try to start it Posted: 02 Mar 2013 05:13 AM PST I just installed Oracle Database Express Edition 11g Release 2 for windows.It created a short cut icon on the desktop : but as I click this icon I see this dialog box : What is it ? How do I start my Oracle Database Server ? |
check constraint that has dynamic list Posted: 02 Mar 2013 04:19 AM PST I need to create a check constraint, the problem i face is that the list of values accepted by the constraint changes in the future (ex:now "red,green and blue" in the next month "red,green,blue and white"). How to do this ? |
Scheduling a backup in SQL Server 2005 Posted: 02 Mar 2013 07:18 AM PST I am trying to schedule back up in SQL Server 2005 with management option. I am unable to find database name while scheduling a backup with full option. Database name is not over there in selected area. What can be the reason? Help me to resolve this problem. |
Can I run a Report Server and a Mirror server from a working Log Shipping secondary instance? Posted: 02 Mar 2013 07:35 AM PST Our setup:
Now there is a lot of data being updated from A - B. And the server in City B is underutilized, and it is a very powerful machine. Can I install a Reporting server and a mirroring server on the server which hosts the secondary logshipping server, and run the Reporting and mirroring server to get the data from the sSecondary logshipping server? We cannot have the data come across 3 times (one for Logs, Report, Mirror) - and the secondary server is updated regularly enough to allow for our requirements. But the secondary logshipping server is obviously always in Standby/Readonly mode - is this all possible? |
which one is the fastest way of moving database form local to live server in sql server Posted: 02 Mar 2013 10:39 AM PST I am using SQL Server 2008, I have big database almost 500 MB of data there. Now I wanted to upload or deploy this DB to Live server. Currently I am generating script and then uploading script to live and by command line I am deploying database. But this took almost 2 hours to do that very cumbersome too. and one more problem is also there I am not able to use import export database option cause its loses constrains like primary key and all and also gets error while inserting record from same process. Can you tell me how can I do all this and with proper data transfer. |
Backup failure in SQL Server 2005 Posted: 02 Mar 2013 01:39 AM PST I'm being unable to perform a backup in SQL Server 2005 installed on Windows 7 local machine. I was initially able to do so but as of now, every time I try I get the following message:
|
What are the advantages of a database design with single table for MtM relationships? Posted: 02 Mar 2013 07:07 AM PST The database that backs our software product has a table design like the following: From the above example, each That means that if I want to get the The advantages of the current approach are:
The disadvantages of the current approach are:
My questions are:
|
Global locking for multi-master Oracle GoldenGate replication Posted: 02 Mar 2013 09:43 AM PST This is a very complex scenario, but I figured a state-of-the-art challenge might interest some of the many high-end users of dba.se. Problem I'm working on an intercontinental data replication solution for a document production system, somewhat similar to a wiki, utilizing Oracle GoldenGate. The primary goals are to increase application performance and availability around the globe. The solution must allow for simultaneous read/write access to the same pool of data from multiple locations, which means that we need some clever way of preventing or resolving conflicting updates without user interaction. Focusing on collision prevention, we must allow an object (a document, an illustration, a set of metadata etc) to be locked globally, thus preventing multiple users from simultaneously editing the same object from different locations - ultimately causing a conflict. Similarly an object must remain locked until any user's connected database have received the updated data for that object, less a user may start editing an old object without the latest updates. Background The application is somewhat latency sensitive, making access to a central data center slow from remote locations. Like many content focused systems, the read/write ratio is in the line of 4 to 1, making it a good candidate for a distributed architecture. If well-managed, the latter wil also work towards ensuring availability during site or network outages. I have used a somewhat unconventional multi-loop bi-directional replication topology. This keeps the complexity at a manageable level {2(n-1) ways}, adds resilience for site outages and allows for fairly simple addition or removal of sites. The slight drawback is that it may take up to 30 seconds for a transaction to be replicated between the most remote sites via the central master database. A more conventional design with direct replication between all sites would cut that time in half, but would also significantly increase the complexity of the configuration {n(n-1) ways}. With five locations that would mean a 20-way replication as opposed to the 8-way replication in my design. This illustration shows my current test environment across data centers in Europe, Asia and North America. The production environment is expected to have additional locations. All the databases are Oracle 11.2.0.3 with Oracle GoldenGate 11.2.1. My thoughts so far I've been thinking along the lines of doing locking by inserting a row into a "locking" table over a database link to the central database, while letting the unlock (update or delete of the previously mentioned row) be replicated along with the updated data. On behalf of the user we must then check the availability of a lock in both the central and local database before acquiring the lock and opening the object for editing. When editing is completed, we must release the lock in the local database which will then replicate the changes and the release of the lock to all other locations via the central database. However, queries over a high latency database link can sometimes be very slow (tests show anywhere from 1.5 seconds to 7 seconds for a single insert), and I'm not sure if we can guarantee that the update or delete statement that removes a lock is the last statement to be replicated. Calling a remote PL/SQL procedure to do the checking and locking will at least limit the operation to a single remote query, but seven seconds is still a very long time. Something like two seconds would be more acceptable. I'm hoping the database links can be optimized somehow. There may also be an additional issues like trying to delete or update a row in the local locking table before that row have been successfully replicated from the central database. On the bright side, with this kind of solution, it should be relatively simple to let the application enter a read-only state if communications to the central database is distrupted, or to redirect clients if a data center should become unavailable. Are there anyone who have done anything similar? What might be the best way to approach this? Like I said initially, this is a rather complex solution, feel free to ask about anything left unclear or left out. |
Posted: 02 Mar 2013 05:31 PM PST My database contains 20,000 rows and the following query is slow. Please help me to speed this up: CREATE TABLE : My EXPLAIN : NOW I change query following : AND faster than before : 1.97s. So somebody help me for speedup more. |
"Waiting for initial communication packet" error 0 in MySQL Posted: 02 Mar 2013 02:01 AM PST I am using MySQL server 5.1.51 on a Linux machine. The application was working fine for the last 32 days, but since yesterday a number of clients are not able to connect to the database from our application. They are getting the following error: What can I do to fix this? |
Posted: 02 Mar 2013 11:30 AM PST I am working with a Firebird 2.1.1 database and I started reading about the Monitoring tables. I am trying to see somehow in real-time what queries does each client performs in the database. I had a look at the Am I looking in the wrong place or did I not understand the purpose / use of the Firebird monitoring tables? |
How to modify an update in Oracle so it performs faster? Posted: 02 Mar 2013 08:11 AM PST I have this query: The trouble that I am having is that this query takes a long time to run. I don't know whether it is possible to run this on parallel, or it would be easier to update a cursor in a pipeline function. What would you suggest? This is all the information that I believe it is relevant. This is the execution plan of the internal select: Table data: This is the script of the historical table: This is the other table: The temporary table is the result of FEE_SCHEDULE_HISTORICAL minus FEE_SCHEDULE |
Get the rank of a user in a score table Posted: 02 Mar 2013 09:00 AM PST I have a very simple MySQL table where I save highscores. It looks like that: So far so good. The question is: How do I get what's a users rank? For example, I have a users An Example In this very case, The query should return one row, which contains (only) the required Rank. |
You are subscribed to email updates from Recent Questions - Database Administrators - Stack Exchange To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No comments:
Post a Comment