database-schema

What's better - many small tables or one big table?

拟墨画扇 提交于 2019-11-27 19:57:19
问题 I've got a database which will store profiles about individuals. These individuals have about 50 possible fields. Some are common things like, first name, last name, email, phone number. Others are things like hobbies, skills, interests Some are height, weight, skin color. Each of these groups are used by the system at different times. In terms of being able to negotiate through the database I would prefer to have 7 tables each of about 8 fields. What is best practice to do? EDIT: The data is

Hierarchical Data - Nested Set Model: MySql

余生长醉 提交于 2019-11-27 18:20:46
问题 I am just learning how to implement the Nested Set Model but still have confusion with a certain aspect of it involving items that may be part of multiple categories. Given the example below that was pulled from HERE and mirrors many other examples I have come across... How do you avoid duplication in the DB when you add Apples since they are multi-colored (i.e. Red, Yellow, Green)? 回答1: You do not avoid duplications and the apple (or a reference to the apple) will be placed twice in your

Rails 3. Creating a production database

此生再无相见时 提交于 2019-11-27 17:24:11
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' && rake db:schema:load Rails.env='production' II. # config/environment.rb # Set the rails environment Rails.env='production' rake db:create && rake db:schema:load ... but neither of them works. Thanks. Debian GNU/Linux 5.0.6; Rails 3.0.0; Sqlite3 3.7.2. Matt Briggs You can set the rails env off of the environment variable RAILS_ENV RAILS_ENV=production bundle exec rake db:create db:schema:load should work Victor S Shouldn't this be RAILS_ENV

Difference between database and schema

一个人想着一个人 提交于 2019-11-27 16:44:05
What's the difference between a Database and a Schema in SQL Server? Both are the containers of tables and data. If a Schema is deleted, then are all the tables contained in that schema also deleted automatically or are they deleted when the Database is deleted? RichardTheKiwi A database is the main container, it contains the data and log files, and all the schemas within it. You always back up a database, it is a discrete unit on its own. Schemas are like folders within a database, and are mainly used to group logical objects together, which leads to ease of setting permissions by schema.

schema builder laravel migrations unique on two columns

微笑、不失礼 提交于 2019-11-27 11:01:18
问题 How can I set a unique constraints on two columns? class MyModel extends Migration { public function up() { Schema::create('storage_trackers', function(Blueprint $table) { $table->increments('id'); $table->string('mytext'); $table->unsignedInteger('user_id'); $table->engine = 'InnoDB'; $table->unique('mytext', 'user_id'); }); } } MyMode::create(array('mytext' => 'test', 'user_id' => 1); // this fails?? MyMode::create(array('mytext' => 'test', 'user_id' => 2); 回答1: The second param is to

Should I use a single or multiple database setup for a multi-client application?

南楼画角 提交于 2019-11-27 10:10:21
I am working on a PHP application that intends to ease company workflow and project management, let's say something like Basecamp and GoPlan . I am not sure on what the best approach is, database-wise. Should I use a single database and add client-specific columns to each of the tables, or should I create a database for each new client? An important factor is automation: I want it to be dead simple to create a new client (and perhaps opening the possibility to signing up for yourself). Possible cons I can think of using one database: Lack of extensibility Security problems (although bugs

How to change schema of all tables, views and stored procedures in MSSQL

混江龙づ霸主 提交于 2019-11-27 10:01:19
问题 Recently we were having issues on our database server and after long efforts it was decided to change the database server. So we managed to restore the database on another server, change the connection string, etc. Everything was going as planned until we tried to access the website from a web browser. We started getting errors about database objects not being found. Later we found out that it occured as a result of the modified schema name. Since there are hundreds of database objects

Need help in developing DB logic

十年热恋 提交于 2019-11-27 09:38:59
This is a mini-project of mine - Airline reservation system - lets call this airline FlyMi : I have a database (Not decided which one, friend of mine wants to go with MongoDB). Anyhoo, this is my requirement : I have a table which has details of the flight - Flight number, schedule etc. I'm going to use this table to perform various operations - booking , cancellation , modification This is where I'm stuck : For the desktop app and the web application - I'm offering an option to select seats. This means I've got to keep track of which seats are booked , which ones are not. And assume I have an

relationships between 3 entities in ER diagram--is a ternary enough or are 2 binaries also needed?

 ̄綄美尐妖づ 提交于 2019-11-27 07:00:56
问题 I'm trying to draw an ER diagram for my project management software describing the following. It contains these entities: project - software projects tasks - software projects that can be broken into a number of tasks employees - employees that belong to this software And: A project can be divided into tasks. (Tasks can be created by the admin user, who can assign those tasks to selected projects. Here there is only assignment of tasks to projects, not assignment of employees to projects.)

How to check if database schema matches Entity Framework schema?

旧街凉风 提交于 2019-11-27 05:59:00
问题 For my surprise, using the CreateDatabaseIfNotExists context initializer, the line context.Database.Initialize(true) doesn't throw an exception if the schema does not match my code first schema. Is there a way to validate if the current database matches our schema before, for instance, we try to access a entity, whose table doesn't exist on the database anymore, and an exception is thrown by EF? 回答1: You can call CompatibleWithModel to determine if the database matches the model. If you set