I'm new to MongoDB. before I start MongoDB i was working with SQL databases. I know that MongoDB is different from SQL and in Mongodb you don't have to define a schema. but if you give your database to other teammates and ask him to work with your database, how he can figure out how to work with a Collection? in this situation in SQL, your teammate will open the database and look at the Table and he will understand how to work with it. Suppose according to your analyze, the User Collection should hold the following data model:
But when you have not defined it anywhere, How can you explain it to others?
I hope that I have been able to express my meaning correctly.
Related
I am using SQL server 2008, and I have created one Database called DemoDb as you can see in below image. I am migrating this existing database to MongoDb now. But I am not aware about Schemas in mongodb. In below image in red square you can see the schemas like admin, login, User etc.
My Question is how I can migrate or create this kind of schema in mongodb. ?
can you please suggest me or help me.
Any help or suggestions will be highly appreciated ...
Thanks
Did you read the MongoDB manual at least?
There is a chapter SQL to MongoDB Mapping Chart which have a useful information for you.
SQL Terms/Concepts - MongoDB Terms/Concepts
table - collection
row - document or BSON document
column - field
table joins - $lookup, embedded documents
...
There is no other way as you must familiarize yourself with MongoDB basics at least.
P.S. MongoDB University have a free courses.
If I use SQLAlchemy's ORM to create objects and store them, does that mean I pretty much also only retrieve the data from the DB via SQLAlchemy? Will the underlying tables created by SQLAlchemy ORM still be sane? Can I still query the DB directly and have useful findings?
The ORM will only create and modify the database records as they're defined. You'll be able to query them just as you normally would. Using SqlAlchemy does not limit your normal database access in any way. SqlAlchemy can output the queries used into log files for seeing what exactly they're doing. It's nothing like html generation where you then don't want to look at the html it created.
I am looking at a way to establish a few tables in my database.
I want to connect every user that logs in to the comments that they leave. There should be 2 or 3 tables. But I have no understanding on how to achieve this. Does anyone know where I can read and learn about how to build table relationships effectively?
You should understand how 'joins' work. They will define how you access your data later.
Check out this site:
http://www.sql-tutorial.net/SQL-JOIN.asp
Even if you don't have MS Access, this is a good tutorial for getting a handle on creating tables and defining relationships.
http://office.microsoft.com/en-us/training/design-tables-for-a-new-access-2007-database-RZ010286445.aspx
Also, "SQL for Dummies" is a great reference to have. Get a used copy on Amazon.
Here's a walk-through for SQL Server 2005: http://dotnetguts.blogspot.com/2007/10/basics-of-sql-server-2005.html
Firstly, let me apologize for the title, as it probably isn't as clear as I think it is.
What I'm looking for is a way to keep sample data in a database (SQL, 2005 2008 and Express) that get modified every so often. At present I have a handful of scripts to populate the database with a specific set of data, but every time the database is changed all the scripts have to be more or less rewritten and I was looking for some alternatives.
I've seen a number of tools and other software for creating sample data in a database, some free and some not. Are there any other methods I haven’t considered?
Thanks in advance for any input.
Edit: Also, if anyone has any advice at all in dealing with keeping data in sync with a changing application or database, that would be of some help as well.
If you are looking for tools for SQL server, go visit Red Gate Software, they have the best tools. They have a data compare tool that you can use to keep lookup type tables up-to-date and a SQL compare tool that you can use to keep the tables synched up between two datbases. So using SQL data compare, create a datbase with all the sample data you want. Then periodically refresh your testing db (or your prod db if these are strictly lookup type tables) using the compare tool.
I also like the alternative of having a script (you can use Red Gate's tool to create scripts) because that means you can store this info in your source control and use it as part of a deployment package to other servers.
You could save them in another database or the same db in different tables distinguished by the name, like employee_test
Joseph,
Do you need to keep just the data in sync, or the schema as well?
One solution to the data question would be SQL Server snapshots. You create a snapshot of your initial configuration, so any changes to the "real" database don't show up in the snapshot. Then, when you need to reset the table, select from the snapshot into a new table. I'm not sure how it will work if the schema changes, but it might be worth a try.
For generation of sample data, the Database project in Visual Studio has functionality that will create fake/random data.
Let me know if this make sense.
Erick
This is a simple question yet I was unable to find any information at all about this.
Is it possible to have sub-schemas in SQL Server 2005/2008?
Example:
Having a HR (Human Resources) schema with a sub-schema called Training (with tables related to this). It would end up like HR.Training.* where * would be the tables.
No. You could fake this with roles by putting different users into different roles and allowing those roles to use objects.
Maybe you could fake it in the naming of the schema, like HR_Training.* and HR_Reviews.* and so forth. Cheesy, I know.
Are you coming from an Oracle background by any chance ? Oracle has the concept of Schemas I believe. In SQL Server the closest equivalent is a Database.
You can cross-query from one database to another on the same SQL server very easily and that would give you virtually the same kind of calling syntax
e.g server.database.owner.object
In you case it might look like HRSvr.HR.dbo.xxx and HRSvr.Training.dbo.xxxx.
yea you can make schemas but doesn't seem like you can make sub-schemas. I come from IBM db2 background but our IT folks here don't seen to know that you can other schemas beside the default 'dbo'.