Relational Database Design Query - database

I am a novice programmer, currently attempting to create a Java EE web application for a dissertation project.
I am currently designing that relational database for my web application and I have created an E-R Diagram for the database:
My query relates to the TeachingClass table. Each class can be taught by one or more Employees (normally a max of 3) and each class can contain one or more pupils (normally around 25). Each teaching class relates to exactly one course, however, there might be a several TeachingClass running simultaneously for each particular course.
From my E-R diagram can someone please confirm that I have set the Teaching Class table correctly, or should I be using two additional joining tables:
One table between TeachingClass and Pupil
One table between TeachingCLass and Employee.
Thanks in advance for any feedback/recommendations provided.

Related

EDR M:N relationship with multiple dependencies

I am in process of designing a reporting tool. the Interface will be C# with backend database. The tool will allow to enter and edit data through an interface and save it to the Database. Additionally, it will provide specific reports, based on the data retrieved from DB.
Currently, I have been trying to solve a M:N relationship in for my DB tables.
The tool lets a user to enter daily Item amounts (Steel and Mesh) based on a Project. I have solved the M:N relationship in the following diagram but I am not sure if this is actually possible and whether I need to break down the daily stats table further, due to a composite key containing 4 PKs from other tables. This is the current diagram i got.
I am wondering whether the diagram has solved the M:N relationship correctly and whether there is a better way to utilise the date table.

Should I let the user create a database?

I'm working on a school register system (it's my first PHP project) and I want it to be available not just for one school. I guess that each school should have its own database. So what I did is that after the user signs up a new school and clicks a "Create a new school register" button, a new database is created with empty tables for teachers, students, attendance etc.
At the same time I have a whole other database with just one table to store all the different schools that are going to sign up. I need it for checking if email already exists and so on.
It works but I sense that this is not how it should be done. Or is it? The app uses one hard-coded database name and then other database names are created by the user. (I've made it so the dynamically created db names have a 'school_' prefix and whatever the user names the school is then appended to it. White spaces are replaced by undescores.)
Do I need to change my approach? Thanks!
There are pros and cons for both approaches and you have to evaluate what is more important to you and how you believe the project is going to evolve.
Pros for having separate databases:
Easier to customize the installation for each school - imagine you get a school that has special requirements, and the easiest way to implement them involves adding columns to tables
Easier to migrate a school to a separate installation of the app - imagine a school gets new management and insists on on-premises hosting after a year
Pros for having a single database:
Easier to upgrade: if a new feature means you need to change the database schema, you only have to change one schema, not one per school
Easier to produce global cross-school statistics: suppose you want a report that has information from different schools - with a single database you only need to run one query, with separate databases you need one query per database
You may also want to think about how you version the source code. If you'll maintain separate versions of the source code for each school so that you can have custom features per school, it makes sense to have separate databases. If you only want to maintain a single version, then it'll probably be easier to have a single database.
I guess it depends on what the requirements are, but I think the simpler approach would be to have a single database. When a new school is created, add an entry to the “schools” table. Have a foreign key “school_id” in each table that links to the “schools” table.

How to visualize relation between objects in a database?

I have a database which I want to visualize in some kind of tool. Let me explain the basic:
Company A does business with Transport Company A and Transport Company B.
Transport Company A does business with Company A, Company B and Company C.
Company C does business with Transport Company A and Transport Company B.
As you can see every Company does business with different Transport Companies and vice versa. These relationships can be implemented in a database, and when drawing a visual model on paper this is also very easy.
Of course the model should contain hundreds of Companies and Transport Companies. So I want to have a visualizing tool, where a overview of these relations can be displayed.
My question is which tools can be used for realizing this?
I think you want to look at Microsoft Visio (get the 2010 version. 2013 is almost unusable from a database standpoint).
But if i am assuming correctly, you want to create a table per company. Don't do this! this can cause redundancy and data integrity problems. you want to create just one table and create what is called a unary many-to-many relationship. This is relationship that can be translated to many different rows can relate to many rows in the same table. I won't go into more detail unless you want me to, as i spent a week or 2 in my Database Design course last month just on many-to-many relationships and gets kinda complicated.

Designing inventory management database?

I am designing data base for inventory management system which is used by nearly 10 to 15 companies. This database contains nearly 25 tables.For designing database i'm planning to use shared schema architecture(ie each schema corresponding to a company and these all schemas are to be placed in a single database).
i want to know whether it is reliable to use shared schema architecture.
can any one please tell me is it correct decision to use above mentioned architecture.
Thanks in advance..
If I read your question, you are suggesting that each company has its own schema. This means two things:
If you decide to implement a basic change in the schema (ie not a change that one company requests), then you will have to implement this change in all the schemae.
You will probably have to implement different logic in your front
end program for each company.
Better you should develop one schema for the entire database; each table would have a field called 'CompanyID' which naturally would define to which company each row belongs. This field would be a foreign key to the Companies table.

ER to Relational mapping to Create statments

I am making a .NET website which makes uses of a database to store information. It's a practice/experimental project not related to work or uni projects.
My question is to with mapping of the ER diagram to a RelationModel and then onto writing the actual create table statements.
following is my ER:
http://img577.imageshack.us/img577/2405/climsyclipboardf.jpg
i'm confused about the part where an entity has ISA relation so it can be two things.
i know how i can for example map Business Account to Account by including all the attributes of Account into Business Account, but not sure if it makes sense when it comes to create statements.
for example, Account is either business or private account has payment of either CC or Direct Debit. How do i do this in create table statements?
For business vs. private accounts, you can make the account type an attribute of the account by implementing it in a column. Now the same thing can be said about CC and Direct Debit. It really depends on how intricate you want to make this system.

Resources