Jump to content

For uni i have to create a web service that will store song playlists and return them to a client (xml). I'm thinking storing all the data in a sql database and then returning that as xml however i can't find out how to add a database to c# website. Been googling for hours and i can't find a nice simple tutorial about creating a database and pulling data from it.

I won't be storing much data is it's just a proff of working for my web services module.

Any help would be great.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/
Share on other sites

Link to post
Share on other sites

Then I hope my uni has sql installed. Would a flat file type of deal work in this situation?

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6349874
Share on other sites

Link to post
Share on other sites

Then I hope my uni has sql installed. Would a flat file type of deal work in this situation?

 

Just point it at your own hosted database and choose a framework such as Entity Framework or NHibernate.

 

Taking EF for example the model is generated either from Code First or Model First so the DDL is easily producible. You could even make things really explicit by creating a deployment SQL script thus I don't really see a problem with it for an academic submission though you may want to check that.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6350159
Share on other sites

Link to post
Share on other sites

Just point it at your own hosted database and choose a framework such as Entity Framework or NHibernate.

 

Taking EF for example the model is generated either from Code First or Model First so the DDL is easily producible. You could even make things really explicit by creating a deployment SQL script thus I don't really see a problem with it for an academic submission though you may want to check that.

I need to create a client and a web service that communicate via XML. I will probably end up hosting the server or using xmapp portable on my USB. I've never done sql in c# before so it's all new to me.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6350309
Share on other sites

Link to post
Share on other sites

I need to create a client and a web service that communicate via XML. I will probably end up hosting the server or using xmapp portable on my USB. I've never done sql in c# before so it's all new to me.

 

The thing that you would need to think about if you tried a flat file is concurrency. In other words you would ultimately end up trying to roll your own DBMS to get around it.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6350475
Share on other sites

Link to post
Share on other sites

The thing that you would need to think about if you tried a flat file is concurrency. In other words you would ultimately end up trying to roll your own DBMS to get around it.

Thats a good point, I'll create a mysql DB and get learning some code to interact with it.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6351934
Share on other sites

Link to post
Share on other sites

Thats a good point, I'll create a mysql DB and get learning some code to interact with it.

 

Maybe also have a think about using the repository pattern for this (plenty of stuff to be found through Google). It would be ideal to make an interface and put all of the implementation detail behind it. This way you can build up a good test framework to verify the behaviour you want is correct irrespective of what technology you choose. It will also mean that if you feel like you have gone or are going down a dead end with a particular implementation then you can easily swap it out later with minimal disruption to the rest of the architecture.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6352146
Share on other sites

Link to post
Share on other sites

Maybe also have a think about using the repository pattern for this (plenty of stuff to be found through Google). It would be ideal to make an interface and put all of the implementation detail behind it. This way you can build up a good test framework to verify the behaviour you want is correct irrespective of what technology you choose. It will also mean that if you feel like you have gone or are going down a dead end with a particular implementation then you can easily swap it out later with minimal disruption to the rest of the architecture.

 

I have the choice of picking a SOAP or REST server, I have done PHP/mysql for a number of years so designing the database won't be an issue. As i said i've never used c# in pull data from the data base before.

 

I have quite a few code examples on my uni's moodle so i will probably have to take a good look at that.

 

Any avice or tips anyone can give at this point are very much appreciated. 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6352437
Share on other sites

Link to post
Share on other sites

SQLite will be the answer to your problems. it acts like a "flat file" in that its literally just a file but acts like a MySQL database in that its a strucutured relational database. it has a .net driver readily available. just look up sqlite in google

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6352457
Share on other sites

Link to post
Share on other sites

SQLite will be the answer to your problems. it acts like a "flat file" in that its literally just a file but acts like a MySQL database in that its a strucutured relational database. it has a .net driver readily available. just look up sqlite in google

yeah i looked that up but doesn't that need installing? in uni i can't install anything so i have to make sure bother the client and the server run with what is there.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6352870
Share on other sites

Link to post
Share on other sites

yeah i looked that up but doesn't that need installing? in uni i can't install anything so i have to make sure bother the client and the server run with what is there.

you will most likely have access installed. just use that. Connect with OBDC.

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6354995
Share on other sites

Link to post
Share on other sites

yeah i looked that up but doesn't that need installing? in uni i can't install anything so i have to make sure bother the client and the server run with what is there.

MySQL would need installed. With SQLite simply make sure the dll is included and your set. Worse case I think you have to have a copy of the dll in the same directory as the executable. Other than that no install required

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6355045
Share on other sites

Link to post
Share on other sites

MySQL would need installed. With SQLite simply make sure the dll is included and your set. Worse case I think you have to have a copy of the dll in the same directory as the executable. Other than that no install required

You missed the point in regards to MySQL. It wouldn't even need to be installed. The whole DDL would be generated from the model.

As for SQLite it's even easier than having to worry about dragging stuff in manually because there's already a NuGet package for it. Just ensure that the appropriate dll/s is set to copy local.

You can still layer an interface and the Entity Framework over the top of this. It makes no difference as it's simply the implementation details.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6356199
Share on other sites

Link to post
Share on other sites

You missed the point in regards to MySQL. It wouldn't even need to be installed. The whole DDL would be generated from the model.

As for SQLite it's even easier than having to worry about dragging stuff in manually because there's already a NuGet package for it. Just ensure that the appropriate dll/s is set to copy local.

You can still layer an interface and the Entity Framework over the top of this. It makes no difference as it's simply the implementation details.

the mysql server would have to be installed, no?

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6360031
Share on other sites

Link to post
Share on other sites

the mysql server would have to be installed, no?

 

Not necessarily - at least not on site. That's why I said:

 

Just point it at your own hosted database and choose a framework such as Entity Framework or NHibernate.

 

Taking EF for example the model is generated either from Code First or Model First so the DDL is easily producible. You could even make things really explicit by creating a deployment SQL script thus I don't really see a problem with it for an academic submission though you may want to check that.

 

In other words the tutor would have everything he/she requires for generating a database right from the data model, (if done properly it would be as implementation agnostic as possible) or simply use the one that the project would be pointed at.

 

The more pragmatic approach is to use something like SQLite (as you said), or some other NoSQL solution of course i.e. it has the advantage of being right there in the project.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
https://linustechtips.com/topic/473858-c-web-service-w-database/#findComment-6360154
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×