|
Schatak wrote: Although worked with SQL server from past 5 years. but now thinking to use MongoDB.
Based on what you posted - bad idea.
Only thing that mongodb might be really good at, starting from zero, is storing and retrieving streaming video. And if if you need that then use mongo for that and use the SQL server for everything else.
|
|
|
|
|
Define BIG Construction....
How much data is involved (written to and read from)?
Mainly simple tables with simple types of bugger and heavier types?
You like to encode/decode JSON all the time?
Which requirements are wanted?
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
I am not very familiar with Powershell. I have been studying how it works with SQL server. I have a few simple scripts but am hoping there are some libraries of cmdlets writen that allow the backup and restore from an ASP . Net application.
|
|
|
|
|
Wouldn't it be easier to execute either as a simple command, as opposed to invoking a powershell script to achieve the same?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
This is my first time of creating a trigger..I tried to create trigger using mysql to count how many "2007" data are in the table when inserting new record but it not working properly it wont display how 2007 data are in my table.......
My table have more than 50 data...
CREATE TRIGGER No_of_Publisher_year Before Insert ON Book FOR EACH ROW SET @Count_No=New.Copyright;
SET @Count_NO=0;
INSERT INTO Book VALUES(14,'Programming Perl','978-0-201-70073-2','WI','2007-12-11',25.23,2,2007);
SELECT Count(@Count_NO) AS 'No_of_publisher_in_year_2007' FROM Book WHERE Copyright=2007
|
|
|
|
|
dili1234 wrote: how many "2007" data are in the table when inserting new record
dili1234 wrote: CREATE TRIGGER No_of_Publisher_year Before Insert
The before keyword may be why you are not seeing the results you expect.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
But though i changed Before into after Nothing happened.I want to see the output of the result how just after inserted new value regarding the query....
|
|
|
|
|
Just a dumb question about composite primary key.
I am designing a DB, then i have a specific problem that having 2 primary keys can only solve.
Now I am wondering if having 2 primary keys could hurt performance. Could it be?
I am using MySQL 5.6, and in MyISAM engine.
Any advice will be appreciated.
Thank you
|
|
|
|
|
There cannot be two primary keys; such is always a design-error.
You can have multiple fields that uniquely identify the field, but only one of them will be the actual primary key. The others are 'candidate keys', 'unique constraints'.
No, you don't need a primary key to define a relation, but I would urge to not to. And yes, it will hurt performance.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Ohh I see, thank you.
But why MySQL accept this query
CREATE TABLE IF NOT EXISTS `tbl_sample`
(
`tbl_sample_id` INT UNSIGNED NOT NULL,
`tracked_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`tbl_sample_id`, `tracked_id`)
)ENGINE = MyISAM
what are you referring about "design-error"? do you mean the design standard or the DBMS itself?
Thank you
|
|
|
|
|
Gilbert Consellado wrote: But why MySQL accept this query ..because it defines a single key, which happens to consist of two fields. It is still a single primary key.
Gilbert Consellado wrote: what are you referring about "design-error"? I mean that there can only be one "primary".
Having multiple fields in a primary key is quite common. Yes, a larger key has a slight performance penalty; it has to check more data than in a single field, and any index containing the key will also grow.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
last question, which is better of the two?
#1
CREATE TABLE IF NOT EXISTS `tbl_sample`
(
`tbl_sample_id` INT UNSIGNED NOT NULL,
`tracked_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`tbl_sample_id`, `tracked_id`)
)ENGINE = MyISAM
#2
CREATE TABLE IF NOT EXISTS `tbl_sample`
(
`tbl_sample_id` INT UNSIGNED NOT NULL,
`tracked_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`tbl_sample_id`),
INDEX `track` (`track_id` ASC)
)ENGINE = MyISAM
|
|
|
|
|
The upper uses two fields to identify a single record. The lower one uses a single field; they would allow different things.
I'd recommend to use the smallest set of fields required. Imagine you are the end-user, how do you differentiate between each record? What is it that makes a sample unique?
If a sample can only be identified by giving both a tbl_sample_id and a track_id, they'd need both be part of the key. If either can be used, then the smallest would become the key, and the other a unique index (the upper in the first case, lower in the second case).
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
You're welcome
|
|
|
|
|
Agree with Eddy... and, if you're of an age, think of "Highlander"... there can be only one.
|
|
|
|
|
ohh, but I don't know what Highlander is
|
|
|
|
|
Highlander - a 1986 sci-fi movie. If you watch it, the comment will become clear.
|
|
|
|
|
Agree with Eddy Vluggen. To add a few things:
- Personally I would define any column combinations that are unique in real world as unique, natural keys, not as primary keys.
- Beyond that I would define a single columns surrogate key for all tables and always fetch/modify rows based on this surrogate key.
For more information, see Surrogate key[^]
|
|
|
|
|
Yup, and Edd save me on this.
But, I am not able or somehow use surrogate keys on this design.
|
|
|
|
|
Just to be clear, as far as I can see, you haven't talked about surrogate keys which is different from composite keys. The idea of surrogate is to have a key which has no relation to the real data, it only serves as an identifier, nothing more.
What comes to usability in your design, I've never seen a situation where surrogate wouldn't be usable, but I'm not familiar with your case.
|
|
|
|
|
I go slightly against the grain here, I use a LinkID field for many to many tables, what you are describing, setting that as the primary key. The 2 foriegn key fields can then have a unique constraint applied.
And yes this adds a performance cost, minor unless you are using serious volumes, but if there are tables referencing the link table you only need the linkid field rather than the 2 fields making up the composite key.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm not good at SQL indulgence.
Am not sure if it's a theme for database or C #.
I want to be able to distinguish when logging into my SQL database if the person has used the correct user name.
As usual connection to SQL Server looks like this in C #. Using SQL connection and not the Windows connection.
SqlConnection con = new SqlConnection ("connection string with the user name here");
con.Open ();
Question: How can I know if the connection with the user name for the SQL server has failed using C # code.
|
|
|
|
|
SqlConnection con = new SqlConnection("connection string with the user name here");
try
{
con.Open();
}
catch (SqlException ex)
{
}
modified 26-Aug-15 8:42am.
|
|
|
|
|
Jörgen Andersson wrote: catch (Exception ex)
You should only be catching exception types which you can handle. In this case, it should be sufficient to catch SqlException .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|