database-schema

copy database structure without data in mysql (with empty tables)

允我心安 提交于 2019-12-02 17:01:13
Is there any way to copy database structure without data in MySQL, so the new database will be the same as it is copied from, but with empty tables. After getting some suggestions I tried the command, but I am getting syntax error, my username = root and password = nothing . I guess the default one. I am trying following command, mysqldump -u root -p -d xyz_db | mysql -u root -p -Dnew_db what I am missing or misplacing in command? Raab mysqldump -u user -ppass -d olddb | mysql -u user -ppass -D newdb The new database must already exist. The -d flag in the mysqldump command prevents copying of

Should this information be calculated in real time or stored in a seperate database?

拜拜、爱过 提交于 2019-12-02 17:01:02
问题 I am working on a group project and we are having a discussion about whether to calculate data that we want from an existing database and store it in a new database to query later, or calculate the data from the existing database every time we need to use it. I was wondering what the pros and cons may be for either implementation. Is there any advice you could give? Edit: Here is more elaborate explanation. We have a large database that has a lot of information being submitted to it daily. We

Change Entity Framework database schema map after using code first

旧时模样 提交于 2019-12-02 11:47:17
问题 I've finished building my blog using EF and Code First. EF was running against my local SQL Express instance, with [DBO] schema. Now i want to publish the blog, and i have done the following : Generetade the scripts for the tables and all objects from SQL Express and change [dbo] to my [administrator] schema from my server. Ran the scripts against the server. No issues, all objects were created an populated just fine. I have modified Webconfig and added my BlogContext connection string to

Duplicate schema name in sequence generation

▼魔方 西西 提交于 2019-12-02 08:01:23
To prevent the usage of the schema attribute in the table annotation to all of my entities, I set the default schema name by the schema.xml: <?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd" version="2.0"> <persistence-unit-metadata> <persistence-unit-defaults> <schema>X</schema> </persistence-unit-defaults> </persistence-unit-metadata> </entity-mappings> And I set it as a mapping file in the persistence.xml:

How to create an in-memory database with schema based on an existing file database

半城伤御伤魂 提交于 2019-12-02 04:46:11
问题 I have an existing database which structure is used accross the whole application. Instances of the databases are periodically rotated. I have a database file template.sqlite which is used as a template for all newly created databases. I want to use it, not a creation script, so that I have to maintain only one file, the empty database template itself. I would like to create an in-memory database with the same structure based on that template file. I know I can open the database and read it's

How to create an in-memory database with schema based on an existing file database

旧巷老猫 提交于 2019-12-02 02:15:40
I have an existing database which structure is used accross the whole application. Instances of the databases are periodically rotated. I have a database file template.sqlite which is used as a template for all newly created databases. I want to use it, not a creation script, so that I have to maintain only one file, the empty database template itself. I would like to create an in-memory database with the same structure based on that template file. I know I can open the database and read it's structure, then create the database manually in memory. If possible, I would like to be able to do it

MySQL: How can I get the timestamp of the last insertion to the database

限于喜欢 提交于 2019-12-01 21:33:05
How can I check when was the last time (timestamp) that I wrote in the database, irrespectively of the database table that I inserted into? Turned out to not be the answer (can't delete as accepted). See comments below this answer. I wasn't able to use information_schema.tables update_time as the column wasn't being updated but for create_time this worked. It would work for update_time (if changed) if update_time gets updated which might be true in your setup. select table_schema,table_name,max_time from information_schema.tables t1 JOIN (select MAX(t2.create_time) AS max_time FROM information

Should I make a foreign key that can be null or make a new table?

本秂侑毒 提交于 2019-12-01 19:30:48
I have a small question concerning with how I should design my database. I have a table dogs for an animal shelter and I have a table owners. In the table dogs all dogs that are and once were in the shelter are being put. Now I want to make a relation between the table dogs and the table owners. The problem is, in this example not all dogs have an owner, and since an owner can have more than one dog, a possible foreign key should be put in the table dogs (a dog can't have more than one owner, at least not in the administration of the shelter). But if I do that, some dogs (the ones in the

MySQL: Embedded JSON vs table

。_饼干妹妹 提交于 2019-12-01 16:22:50
I'm designing the database schema for a video production project management app and struggling with how to persist some embedded, but not repeatable data. In the few CS courses I took, part of normalizing a relational database was identifying repeatable blocks and encapsulating them into their own table. What if I have a block of embedded/nested data that I know is likely to be unique to the record? Example: A video record has many shoot_locations . Those locations are most likely never to be repeated. shoot_locations can also contain multiple shoot_times . Representing this in JSON, might

MySQL: Embedded JSON vs table

旧巷老猫 提交于 2019-12-01 14:45:16
问题 I'm designing the database schema for a video production project management app and struggling with how to persist some embedded, but not repeatable data. In the few CS courses I took, part of normalizing a relational database was identifying repeatable blocks and encapsulating them into their own table. What if I have a block of embedded/nested data that I know is likely to be unique to the record? Example: A video record has many shoot_locations . Those locations are most likely never to be