database-schema

Handling migrations with MongoDb

孤者浪人 提交于 2019-11-30 08:28:13
Just to give a little more context to the question, I have a web application (asp mvc) which basically wraps CRUD operations to a MongoDb instance, it carries out validation and certain business logic before the model is verified and sent over to be stored, retrieved etc. Now one problem we have his is that in the new version the models have changed but the existing data has not, here is an example: (it is c# specific but the question really is language agnostic) public class Person { public Guid Id {get; set;} public string Name {get; set;} public int Age {get;set;} public string BadgeNo {get

What is the purpose of the ConcurrencyStamp column in the AspNetUsers table in the new ASP.NET MVC 6 identity?

不想你离开。 提交于 2019-11-30 07:49:57
What is the purpose of the ConcurrencyStamp column in the AspNetUsers table in the new ASP.NET MVC 6 identity? This is the database schema of the AspNetUsers table: It is also there in the AspNetRoles table: As I remember it wasn't there in the ASP.NET MVC 5 identity. What I've noticed so far is that it seems to have GUID values as it is defined with the following code: /// <summary> /// A random value that must change whenever a user is persisted to the store /// </summary> public virtual string ConcurrencyStamp { get; set; } = Guid.NewGuid().ToString(); But this documentation is not

Followers - mongodb database design

佐手、 提交于 2019-11-30 06:47:11
问题 So I'm using mongodb and I'm unsure if I've got the correct / best database collection design for what I'm trying to do. There can be many items, and a user can create new groups with these items in. Any user may follow any group! I have not just added the followers and items into the group collection because there could be 5 items in the group, or there could be 10000 (and the same for followers) and from research I believe that you should not use unbound arrays (where the limit is unknown)

Duplicate postgresql schema including sequences

£可爱£侵袭症+ 提交于 2019-11-30 05:20:19
问题 My database layout needs to create new schema for each new customer. Currently I use internal function I found on the net and modified a little bit. CREATE FUNCTION copy_schema( source_schema character varying, target_schema character varying, copy_data boolean) RETURNS integer AS $BODY$ DECLARE t_ex integer := 0; s_ex integer := 0; src_table character varying; trg_table character varying; BEGIN if (select 1 from pg_namespace where nspname = source_schema) THEN -- we have defined target

Why is database view used?

做~自己de王妃 提交于 2019-11-30 03:17:43
问题 Is using "view" in db design right method or we should handle it code side? What are the advantages or disadvantages? 回答1: I see a couple of reasons to use views : Provide a simpler interface : just query the view, and not a dozen tables, doing joins and all Provide an interface that doesnt change (or less often) : Even if you change the structure of the tables, you might be able to modify your view so it still returns the same thing Which means no change is needed in your application's code

How to support Multi-Languages approach in DataBase Schema?

假装没事ソ 提交于 2019-11-30 03:00:38
问题 I want my database to support multi Languages for all text values in its tables. So what is the best approach to do that?. Edit1:: E.G. I've this "Person" table: ID int FirstName nvarchar(20) LastName nvarchar(20) Notes nvarchar(max) BirthDate date ........... So if i want my program to support new language "let say French". should i add new column every time i add new language ? So my "Person" table will look like this ID int FirstName_en nvarchar(20) FirstName_fr nvarchar(20) LastName_en

Schema Builder length of an integer

半城伤御伤魂 提交于 2019-11-30 01:51:42
问题 I've been searching around and the question was asked a few times, but no-one seem to be able to give a definite answer to it. How do you specify the integer length for the table column using Schema? I've seen someone suggesting: $table->integer('post')->length(11); But that doesn't work - at least with Laravel 4.2 - it still produces the column as int(10) . Is there a built in method to specify the integer length? 回答1: If you're using MySQL, you can't specify the length of an integer column.

Add constraint to existing SQLite table

泪湿孤枕 提交于 2019-11-30 01:42:27
问题 I'm using SQLite, which doesn't support adding a constraint to an existing table. So I can't do something like this (just as an example): ALTER TABLE [Customer] ADD CONSTRAINT specify_either_phone_or_email CHECK (([Phone] IS NOT NULL) OR ([Email] IS NOT NULL)); Are there any workarounds for this scenario? I know: I can add a constraint for a new table, but it isn't new (and it's generated by my ORM, EF Core) I can do a "table rebuild" (rename table, create new one, copy old data, drop temp

How to manually set seed value as 1000 in MySQL

梦想与她 提交于 2019-11-30 01:40:23
问题 I am using MySQL 5. I need to set the seed value as 1000 for my auto increment field. How can I set it? 回答1: To set when creating your table: CREATE TABLE xxx(...) AUTO_INCREMENT = 1000; To set after creating the table: ALTER TABLE xxx AUTO_INCREMENT = 1000; 回答2: If the table already exists, you can do this: ALTER TABLE mytable AUTO_INCREMENT = 1000; But make sure the highest value in the auto_increment column is less than 1000. If you are creating a new table, you can do this: CREATE TABLE

Database with “Open Schema” - Good or Bad Idea?

点点圈 提交于 2019-11-29 23:08:11
The co-founder of Reddit gave a presentation on issues they had while scaling to millions of users. A summary is available here . What surprised me is point 3: Instead, they keep a Thing Table and a Data Table. Everything in Reddit is a Thing: users, links, comments, subreddits, awards, etc. Things keep common attribute like up/down votes, a type, and creation date. The Data table has three columns: thing id, key, value. There’s a row for every attribute. There’s a row for title, url, author, spam votes, etc. When they add new features they didn’t have to worry about the database anymore. They