database-schema

Is there a way to disconnect a Visual Studio 2008 Schema Compare from a database without closing the schema compare?

Let's say I want to (using Visual Studio) run a schema comparison between two databases, restore one of them from a backup, and run the schema comparison again. The schema comparison maintains a connection to the database, and SQL Server won't let me run the restore without removing all connections. Is there a way I can force the schema ...

Why are schema capitalizations inconsistent in Visual Studio database projects?

So I've run into a somewhat maddening bug (perhaps) with Visual Studio database projects, specifically in 2010 Ultimate. Basically, let's say I have two .schema.sql files, like so: File 1 CREATE SCHEMA [Test] GO File2 CREATE SCHEMA [AuditTest] GO This compiles down and is deployed as: PRINT N'Creating [AuditTest]...'; GO CREAT...

Autogenerating schema from NHibernate attribute annotated types

I want to export a schema from my types annotated with NHibernate attributes. Is this possible? My current code is below, needless to say, it compiles, but the expected table TestType does not get created. I have a type as follows: [Serializable, Class(Schema = "test")] public class TestType { [Property] ...

How to change the schema for a diagram?

Hi, Diagrams created with Microsoft SQL Server Management Studio have their default schema set to dbo. It seems that there is no way to set another schema when creating a diagram. For tables, alter schema NewSchemaName transfer dbo.TableName moves a specified table to the new schema. But the same command does not work for diagrams. ...

Alternatives to boolean flags in MySQL tables?

I'm using various boolean flags in my tables, and from reading a bit about optimizing performance I came across a widespread tip to avoid using boolean flags. What are the effective alternatives? Some examples would be much appreciated. ...

Rails: How to create databse schema with ActiveRecord::Schema like in django?

I like Rails, but I'm not a big fan of migrations. How can I use the ActiveRecord::Scema tool to create a database without using SQL and without migrations? I know you use it like this: ActiveRecord::Schema.define do create_table :authors do |t| t.string :name, :null => false end add_index :authors, :name, :unique...

Need assistance with Database Schema (platform independant)

Good morning everyone, Please read everything before answering. I have sort of an opinion question but at the same time one that may have a right answer. I'm trying to develop a suite of products and want to make sure that since I'm doing it myself, that I do it right the first time. I've re-wrote the schema multiple times, each time...

Code to generate SQL Server table schema from ADO.NET

I'd quite like to use ADO.NET to generate a CREATE TABLE script to create an exact copy of a given table. The reason for this is persistence testing. I would like to know whether my application will persist to a particular database. I would like to be able to point the app to the database and table in question, and then the app will gen...

In RDBMS, is there a formal design principle for Concrete objects, such as Course vs CourseSession?

In designing RDBMS schema, I wonder if there is formal principle of concrete objects: for example, if it is Persons table, then each record is very concrete and unique. Each record in fact represents a unique person. But what about a table such as Courses (as in school). It can have a description, number of units, offered only in Autu...

Rails 3. Creating a production database

Hi. How can I create a production database in Rails 3 and load a schema to it? I tried the following approaches... I. rake db:create Rails.env='production' Rails 3.0.0; Sqlite3 3.7.2. ...

Is there a reason that the primary key is nchar while other fields are nvarchar?

I am working through an example from MSDN that uses a small database to demonstrate data driven testing, and here is the simple schema: CREATE TABLE dbo.LogonInfoTest ( UserId nchar(256) NOT NULL PRIMARY KEY CLUSTERED, Password nvarchar(256) NULL, IsValid bit NOT NULL ) ON [PRIMARY] GO My question is: What is the under...

How would you model this in MongoDB?

There are products with a name and price. Users log about products they have bought. # option 1: embed logs product = { id, name, price } user = { id, name, logs : [{ product_id_1, quantity, datetime, comment }, { product_id_2, quantity, datetime, comment }, ... , {...

How would you implement these queries efficiently in MongoDB?

Links have one or more tags, so at first it might seem natural to embed the tags: link = { title: 'How would you implement these queries efficiently in MongoDB?' url: 'http://stackoverflow.com/questions/3720972' tags: ['ruby', 'mongodb', 'database-schema', 'database-design', 'nosql']} How would these queries be imple...

DB Schema for Facebook like Wall + "Shared links"

Hi, I am making a db schema for facebook like wall structure. I need to save wall posts, share a link, share a video stuff into my database. Till now I am able to make this schema : GO CREATE TABLE [Wall] ( [ID] [int] NOT NULL IDENTITY(1, 1) , [PostText] [nvarchar](MAX) [PostedByUserID] [int] NULL , [PostedO...

SQL Server ASP Schema option

In my Godaddy hosting account I have an option to set up ASP Schema with my SQL Server 2005 database. It describes in very general terms what the option is: "ASP.NET configuration schema contains elements that control how ASP.NET Web applications behave." Can someone explain to me(or provide a link) in greater detail as to what that doe...

How can dbms_metadata from Oracle produce constraints seprate from the table schema files?

Why is dbms_metadata.set_transform_param(dbms_metadata.session_transform, 'CONSTRAINTS_AS_ALTER', TRUE) not generating constraints in separate files? At this moment this pl/sql pastes the constraints after the table schema definition files. What flag do I have to use to achieve this separate constraints schema definition directory? ...

SQL Server CE Schema Compare Tool

Is there any tool which schema compares directly 2 SQL CE databases. VS2010 not working for CE as well as every commercial tool i have seen. How would you approach this problem? ...

Proper Table Schema

I have a project that I am working on and I can't figure out which would be a "better" table relationship schema. The scope of the area in question are: -User uploads documents (become the owner/author) -User can share document with other users (set share rights) -Any user who has access to document can checkout the document (exclusi...

where are C# ADO.NET DbConnection.GetSchema "attributes" defined?

I find this whole GetSchema thing awfully complex. Is there any decent documentation for all this at all? One would expect that normal use is to get data for table: indexes and columns(name, type, allownulls) and then have method(s) to ask these properties. One might also expect that these properties would be enum or even a webpage that ...

How can I find all columns that are filled with 100% nulls in my SQL Server database schema?

Is there a SQL way to find out which columns in my schema are completely full of null values? There are some fields in a couple of tables that I know are not used by the application and will be dropped, but I wanted to see if there was an automated way/script to find this out across the whole database to find candidates for code review/...