Best practices are generally and informally recognized as the methods and processes that have been shown over time to be superior to those achieved by other means.

learn more… | top users | synonyms

1
vote
0answers
22 views

Key/value table: what is a good way to organize it if value could be foreign key?

Suppose a have a structure of two tables Table Key names: |_Key name_|_Parent_key_id_| | key1 | NULL | | key2 | key1 | Table Key values: |_Key__|_Value__|_Version__| | ...
95
votes
6answers
32k views

When should I use a unique constraint instead of a unique index?

When I want a column to have distinct values, I can either use a constraint create table t1( id int primary key, code varchar(10) unique NULL ); go or I can use a unique index create table t2( id ...
6
votes
2answers
92 views

SQL perf issue - configure server correctly first or troubleshoot issues one by one?

This is for SQL Server 2012. I am troubleshooting overall slow performance on a Dynamics AX environment. Everything is just slow - app itself, reports, ad-hoc, etc. Right off the bat, I can see ...
2
votes
0answers
15 views

What is the best way to keep track of 1000 RDS hosted databases?

I want to know what is 'best-practices' for managing an extreme number of RDS instances. I have no problem managing five. But managing dozens or hundreds, that's another task. I'm thinking use a ...
1
vote
2answers
42 views

How to Apply a Title-Case RegEx Condition for Object Names with Policy Based Management

I'm implementing PBM on a SQL Server 2014 instance and want to enforce a condition that all objects are created outside the dbo schema and all object names are created in title-case (i.e., OrderDetail)...
14
votes
3answers
165 views

Transaction Log Backups Serial or Parallel?

We happen to be using SQL Server 2012 Standard Edition. I also happen to use Ola Hallengren's scripts to provide an easy, more flexible framework for doing backups and maintenance. This question isn'...
3
votes
1answer
54 views

Is EXECUTE AS OWNER in msdb a security risk?

I've been tasked with creating a system that allows non-privileged users to start and stop SQL Server Agent jobs. I'm creating stored procedures in the dbo schema in the msdb database using the WITH ...
3
votes
1answer
36 views

Store the content book in database, so that it would be updated afterwards or store them as document?

I have some books in (urdu) made with Urdu Inpage(tool for making pages in urdu) like this: problem that these document files are difficult to read in php because they gives unread-able characters, ...
3
votes
3answers
3k views

Best practices for configuring the Drive/Filegroup setup for Microsoft SQL 2008

I am a software developer for a small company. I wish we had a dba but that is not on the cards at this point. I was working on migrating our 75GB SQL Server 2000 database to SQL Server 2008 R2. The ...
45
votes
3answers
29k views

Is it a bad practice to always create a transaction?

Is it a bad practice to always create a transaction? For example, it is a good practice to create a transaction for nothing but one simple SELECT? What is the cost of creating a transaction when it ...
46
votes
12answers
5k views

How could DBAs be more 'programmer friendly'?

The answers and comments on the dba.se version and programmers.se version of the question "What are the arguments against or for putting application logic in the database layer?" are very revealing ...
6
votes
1answer
176 views

Principle of least privilege for sql server agent jobs

I've just read this article which advocates using the sa account for ownership of sql server agent jobs. http://sqlmag.com/blog/sql-server-tip-assign-ownership-jobs-sysadmin-account He has a couple ...
21
votes
8answers
2k views

What problems are solved by splitting street addresses into individual columns?

We have a team who designs the tables and relations for software developers. In our organization, they are pretty strict about enforcing 3NF normalization - which to be honest, I agree with given the ...
3
votes
2answers
8k views

changing float->numeric casts from assignment to implicit, dangerous?

In porting an application to PostgreSQL (9.1), one odd SQL incompatibility I've discovered concerns the round() function, specifically the version that takes a second argument indicating the rounding ...
126
votes
18answers
30k views

Should developers be able to query production databases?

Should developers be given permission to query (SELECT / read only) production databases? The previous place I worked, the development team had the db_datareader role; where I work now the ...
27
votes
4answers
14k views

PostgreSQL Stored Procedure Performance

Coming from a MySQL background, where stored procedure performance (older article) and usability are questionable, I am evaluating PostgreSQL for a new product for my company. One of the things I ...
0
votes
0answers
53 views

Comparisons with NULL values and not using ISNULL function

Hello and thank you in advance. My question is that with ansi-nulls on, how can I do a proper comparison between two fields without using an isnull function (or coalesce)? For example the following ...
1
vote
1answer
33 views

Login Schema Role User Setup

Environment: Windows Server 2012 SQL Server 2014 Standard Public website (Site-A) on Server Private website (Site-B) on Server Windows App running on workstations SQL Server 2014 Standard: 2 ...
31
votes
5answers
80k views

Sql Server Maintenance Plan - Best Practices on Tasks and Scheduling

I am tasked with devising a maintenance plan for our Sql Server 2005 databases. I know for backups I want to do a daily full database backup and transactional log backups every 15 minutes. My problem ...
18
votes
1answer
570 views

Setting BUFFERCOUNT, BLOCKSIZE, and MAXTRANSFERSIZE for BACKUP command

I am looking for practical guidance for setting the values for the BUFFERCOUNT, BLOCKSIZE, and MAXTRANSFERSIZE of the BACKUP command. I have done a bit of research (see below), I have done a bit of ...
4
votes
2answers
62 views

MySQL: Soft Delete post likes

I have implemented a like/unlike features for posts in one of my projects. The like table is normalized and has a column visible. The schema is as follows: Column Type Null Default ...
0
votes
2answers
81 views

Select max(pk) instead of sequence.nextval

I have a client/superior who keeps suggesting that I select max(primary_key) when I insert a new row. I gut says it's VERY wrong but I don't have exact reasons to support my suggestion. The only ...
0
votes
0answers
15 views

Relationship based access control (ReBAC)

In my application, access control is based on relationships between entities. Consider this simplified schema: CREATE TABLE user (...); CREATE TABLE group (...); CREATE TABLE group_members( ...
1
vote
1answer
454 views

Is introducing a where condition into the join clause bad practice

In the query below, the condition and r.master_seq=206 is used on the on clause as a join condition. In the programme code, the value for r.master_seq is set by a parameter. My concern is ...
12
votes
6answers
9k views

Splitting Tables in MySQL. Good practice?

I have started working on an existing project and the previous developer had split up a table into 10 separate tables with identical schemas but different data. The tables look like this: [...
28
votes
1answer
10k views

Best practices for schema changes and data migrations to a live database without downtime?

How do you make schema changes to a live database without downtime? For instance, lets say I have a PostgreSQL database with a table including various user data like email addresses etc, all ...
1
vote
1answer
286 views

structure when storing books in elasticsearch

I want to use elasticsearch as a web search engine for books. A book has several editions with different titles in different languages, ISBN's as well as author names in different languages. I want ...
1
vote
1answer
91 views

Should child comment be treated as separate table?

I'm building a commenting system, currently my table indicates which comment is child with parent id in 1 table, I would like to know what is the best way of doing this? Current Table Scheme (1 Table)...
0
votes
0answers
46 views

How much normalization is too much

I am working on designing a database for a site I am trying to build, I created what I believe to be the best normalization strategy, to limit the size of particular tables, and the number of tables ...
4
votes
1answer
226 views

Is splitting a CSV column into a separate table(enforcing 1nf) unnecessary complication?

I had very carefully asked the table designer why he had chosen to create CSV columns in multiple tables. The designer's answer was that splitting CSV columns into separate tables was unnecessarily ...
1
vote
1answer
44 views

Chance of duplicate on single select max into statement

Against my will, I am told to use the following method to generate a new pk value. INSERT INTO SERVER_MONITERING(SM_SEQ, CPU_USE, MEMORY_BASE, MEMORY_USE, DISK_BASE, DISK_USE, SERVER_IP,...
6
votes
1answer
66 views

How to encode a known date but unknown year?

I am using a Postgres database, and have a table with a date-time field. For many records, we know the year but not the date. Sometimes we know the date but not the year. And other times we know the ...
0
votes
0answers
171 views

A “best practice” Postgresql function template for ETL processes

I use SQL Server in my day job, and have a personal project to build a star schema data warehouse in Postgres 9.4 on Ubuntu 14.04 to extend my knowledge (it'll be approximately 300GB uncompressed). I'...
0
votes
1answer
38 views

Consultants using old version of Hibernate ORM for new application - should I be concerned?

My company currently has consultants developing a Java-based application. They are using Hibernate ORM 3.5 (released 5 1/2 years ago in 2010) in this application. The back-end is SQL Server 2012. ...
0
votes
1answer
30 views

Upgrading a big database inside a transaction

Assuming a big database, where normal upgrade (structural changes and data upgrade) currently takes about 2-3 days (not a issue, is not done during production and about 1-2 times per year. Currently, ...
1
vote
1answer
50 views

Is it recommend to create a table for addresses? [closed]

I have a table persons with the columns per_id, per_passport, per_name and per_address. Two or more persons can live in the same address (like families or room-mates) so if this happened, the data is ...
20
votes
3answers
904 views

When is it better to create STATISTICS instead of creating an Index?

I have found plenty of information on what STATISTICS are: how they are maintained, how they can be created manually or automatically from queries or indexes, and so on. But, I have been unable to ...
2
votes
3answers
224 views

Table naming and Database normalization

I'm creating a database of simulation results, and am trying to do so the right way. I've attempted to show relationships between data to make sure nothing redundant is thrown in. My current ...
47
votes
3answers
119k views

Granting access to all tables for a user

I'm a new to Postgres and trying to migrate our MySQL databases over. In MySQL I can grant SELECT, UPDATE, INSERT, DELETE privileges on a low privileged user and enable those grants to apply to all ...
2
votes
2answers
151 views

Tables names in a supertype/subtype schema [closed]

I have 3 types of users in my app. The users share some common attributes, but they also have quite a bit of stuff that pertains uniquely to each user type. I have a person table that contains limited ...
0
votes
2answers
18k views

When should I NOT set the Maximum Server Memory option in SQL Server?

In SQL Server, I normally set the Maximum Server Memory setting to one of the popular best practices, such as leaving 10% or 4GB, whichever is higher. http://www.brentozar.com/archive/2012/11/how-to-...
9
votes
5answers
7k views

Parallelism Best Practices

What are the best practices with setting parallelism in general? I know that SQL Server defaults to 0 to use all available processors, but in what instance would you want to change this default ...
2
votes
1answer
157 views

Organizing Database Objects in a Database that are not part of the systems original Database Objects?

I've been working at a place for about 2 years now with a series of heterogeneous legacy database applications, which are tied together using 3rd party Microsoft Access databases (*.mdb). Soon we ...
2
votes
1answer
145 views

Best Practice for Passing and Working With Parameters Security/Performance

Our senior programmer has been having me write stored procedures in the following format to protect against injection attacks. He says that the best practice is to take the parameter in, then declare ...
3
votes
1answer
9k views

Efficient way to insert/update/delete table records from complex query in Postgres 9.x

I have this function which returns a set a records and I need to persist those records into a table. I have to do it hundred times a day. My initial approach was just clear data from my table and re-...
1
vote
0answers
68 views

Is not having 'named' timezone support common in MySQL?

I'm trying to set the timezone the database uses using: "SET time_zone = 'UTC'; Whilst this works on my development server it doesn't work on my staging server; I get this error: General error: ...
0
votes
0answers
127 views

User is An employee. Role or relation

I've created a database based on a party-model. In short I show you the tables: parties, kind, party_to_party_relations, role, party_roles table parties: CREATE TABLE `parties` ( `id` int(11) NOT ...
17
votes
2answers
37k views

Database model with users, roles and rights

I have a database model with a user table and role table. I want to control the access (rights) to up to 10 different elements. The access can be granted to either a role or a single user. Below is ...
4
votes
2answers
721 views

Storing Passport Numbers in a database

We're developing a travel/tourist application for a tours company who want to be able to input traveler information into an online database. Is there any security best practice for storing passport ...
5
votes
2answers
34k views

Using Same CASE WHEN Conditions For Multiple Query Columns

Is there a "better" way to rewrite a SELECT clause where multiple columns use the same CASE WHEN conditions so that the conditions are only checked once? See the example below. SELECT CASE ...